update image material

This commit is contained in:
Nick Fisher
2024-02-16 20:37:07 +08:00
parent 2ae3f8c466
commit 8107258a1e
5 changed files with 2306 additions and 1549 deletions

View File

@@ -8,5 +8,5 @@ IMAGE_PACKAGE:
IMAGE_IMAGE_OFFSET:
.int 0
IMAGE_IMAGE_SIZE:
.int 36070
.int 51248

View File

@@ -8,5 +8,5 @@ _IMAGE_PACKAGE:
_IMAGE_IMAGE_OFFSET:
.int 0
_IMAGE_IMAGE_SIZE:
.int 36070
.int 51248

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -11,7 +11,7 @@ material {
precision : high
},
{
type : float3,
type : float4,
name : backgroundColor
},
{
@@ -38,17 +38,15 @@ vertex {
fragment {
void material(inout MaterialInputs material) {
prepareMaterial(material);
vec4 bg = vec4(materialParams.backgroundColor, 1.0);
highp vec2 uv = (materialParams.transform * vec4(saturate(variable_imageUV.st), 1.0, 1.0)).st;
highp vec2 uv = (materialParams.transform * vec4(saturate(variable_imageUV.st), 1.0, 1.0)).st;
if (materialParams.showImage == 0 || uv.s > 1.0 || uv.s < 0.0 || uv.t < 0.0 || uv.t > 1.0) {
material.baseColor = bg;
material.baseColor = materialParams.backgroundColor;
} else {
uv.t = 1.0 - uv.t;
vec4 color = max(texture(materialParams_image, uv.st), 0.0);
color.rgb *= color.a;
// Manual, pre-multiplied srcOver with opaque destination optimization
material.baseColor.rgb = color.rgb + bg.rgb * (1.0 - color.a);
material.baseColor.rgb = color.rgb + materialParams.backgroundColor.rgb * (1.0 - color.a);
}
}
}