This commit is contained in:
xsl
2025-09-04 10:54:47 +08:00
commit 6bc8f61b18
1808 changed files with 208268 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
#version 450
/* Copyright (c) 2024, Google
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout (location = 0) in vec2 inUV;
////////////////////////////////////////
layout(set = 0, binding = 0) uniform SceneConstants
{
mat4 model_view_projection;
float background_grayscale;
float object_alpha;
int front_layer_index;
int back_layer_index;
} sceneConstants;
////////////////////////////////////////
layout(set = 0, binding = 1) uniform sampler2D backgroundTex;
////////////////////////////////////////
layout(location = 0) out vec4 outColor;
void main()
{
outColor = texture(backgroundTex, inUV) * sceneConstants.background_grayscale;
}
Binary file not shown.
+55
View File
@@ -0,0 +1,55 @@
#version 450
/* Copyright (c) 2024, Google
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout (location = 0) in vec2 inUV;
layout (location = 0) out vec4 outFragColor;
////////////////////////////////////////
layout(set = 0, binding = 0) uniform SceneConstants
{
mat4 model_view_projection;
float background_grayscale;
float object_alpha;
int front_layer_index;
int back_layer_index;
} sceneConstants;
const int kLayersCount = 8;
layout(set = 0, binding = 2) uniform sampler2D layerTex[kLayersCount];
////////////////////////////////////////
void main()
{
// Merge all layers using in-shader alpha blending.
vec4 color = vec4(0.0f, 0.0f, 0.0f, 1.0f);
const int front_layer_index = clamp(sceneConstants.front_layer_index, 0, kLayersCount - 1);
const int back_layer_index = clamp(sceneConstants.back_layer_index, front_layer_index, kLayersCount - 1);
for(int i = back_layer_index; i >= front_layer_index; --i)
{
const vec4 fragmentColor = texture(layerTex[i], inUV);
color.rgb = mix(color.rgb, fragmentColor.rgb, fragmentColor.a);
color.a *= 1.0f - fragmentColor.a;
}
// The final color is blended in the background using fixed-function alpha blending.
color.a = 1.0f - color.a;
outFragColor = color;
}
Binary file not shown.
+35
View File
@@ -0,0 +1,35 @@
#version 450
/* Copyright (c) 2024, Google
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout (location = 0) out vec2 outUV;
////////////////////////////////////////
void main()
{
const vec4 fullscreen_triangle[] =
{
vec4(-1.0f, 3.0f, 0.0f, 2.0f),
vec4(-1.0f, -1.0f, 0.0f, 0.0f),
vec4( 3.0f, -1.0f, 2.0f, 0.0f),
};
const vec4 vertex = fullscreen_triangle[gl_VertexIndex % 3];
gl_Position = vec4(vertex.xy, 0.0f, 1.0f);
outUV = vertex.zw;
}
Binary file not shown.
+45
View File
@@ -0,0 +1,45 @@
#version 450
/* Copyright (c) 2024, Google
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout (location = 0) in vec4 inColor;
layout (location = 0) out vec4 outFragColor;
////////////////////////////////////////
layout(set = 0, binding = 1) uniform sampler2D depthTex;
////////////////////////////////////////
void main()
{
// 'depthTex' contains the depth information of the previous layer.
// That information is used to discard any fragment that belongs to
// a layer that has already be rendered (i.e. a layer further in front).
const float layerDepth = texelFetch(depthTex, ivec2(gl_FragCoord.xy), 0).r;
if(gl_FragCoord.z >= layerDepth)
{
// NOTE
// Remember that a reversed Z-buffer is used here.
// Fragments closer to the camera have a higher z coordinate.
discard;
}
outFragColor = inColor;
}
Binary file not shown.
+42
View File
@@ -0,0 +1,42 @@
#version 450
/* Copyright (c) 2024, Google
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout (location = 0) in vec3 inPos;
layout (location = 1) in vec2 inUV;
layout (location = 0) out vec4 outColor;
////////////////////////////////////////
layout(set = 0, binding = 0) uniform SceneConstants
{
mat4 model_view_projection;
float background_grayscale;
float object_alpha;
int front_layer_index;
int back_layer_index;
} sceneConstants;
////////////////////////////////////////
void main()
{
gl_Position = sceneConstants.model_view_projection * vec4(inPos, 1.0f);
outColor = vec4(inUV, 0.0f, sceneConstants.object_alpha);
}
Binary file not shown.
@@ -0,0 +1,31 @@
#version 450
/* Copyright (c) 2024, Google
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout (location = 0) in vec4 inColor;
layout (location = 0) out vec4 outFragColor;
////////////////////////////////////////
void main()
{
// The first gather pass is equivalent to rendering an opaque object.
// That is, only the front-most fragments are rendered.
outFragColor = inColor;
}
Binary file not shown.