@@ -32,6 +32,12 @@
|
|
32
32
|
camInstance.clearFlags = ClearFlags.SolidColor;
|
33
33
|
camInstance.backgroundColor = new RGBAColor(0.5, 0.5, 0.5, 1);
|
34
34
|
camInstance.fieldOfView = 35;
|
35
|
+
|
36
|
+
const transparentAttribute = evt.context.domElement.getAttribute("transparent");
|
37
|
+
if (transparentAttribute != undefined) {
|
38
|
+
camInstance.clearFlags = ClearFlags.Uninitialized;
|
39
|
+
}
|
40
|
+
|
35
41
|
// TODO: can we store the backgroundBlurriness in the gltf file somewhere except inside the camera?
|
36
42
|
// e.g. when we export a scene from blender without a camera in the scene
|
37
43
|
camInstance.backgroundBlurriness = .2; // same as in blender 0.5
|
@@ -55,6 +55,7 @@
|
|
55
55
|
|
56
56
|
export type TonemappingAttributeOptions = "none" | "linear" | "neutral" | "agx";
|
57
57
|
type RenderingAttributes = {
|
58
|
+
"transparent"?: boolean,
|
58
59
|
"contactshadows"?: boolean,
|
59
60
|
"tone-mapping"?: TonemappingAttributeOptions,
|
60
61
|
"tone-mapping-exposure"?: number,
|
@@ -127,6 +127,7 @@
|
|
127
127
|
context.renderer.domElement.style.height = height + "px";
|
128
128
|
|
129
129
|
const previousClearColor = context.renderer.getClearColor(new Color());
|
130
|
+
const previousClearAlpha = context.renderer.getClearAlpha();
|
130
131
|
|
131
132
|
try {
|
132
133
|
if (opts?.transparent) {
|
@@ -168,7 +169,7 @@
|
|
168
169
|
finally {
|
169
170
|
context.renderer.setSize(prevWidth, prevHeight, false);
|
170
171
|
context.updateSize();
|
171
|
-
context.renderer.setClearColor(previousClearColor);
|
172
|
+
context.renderer.setClearColor(previousClearColor, previousClearAlpha);
|
172
173
|
}
|
173
174
|
|
174
175
|
return null;
|
@@ -83,7 +83,7 @@
|
|
83
83
|
}
|
84
84
|
|
85
85
|
// Calculate the sharpened color using inputColor
|
86
|
-
vec4 sharp = inputColor + (inputColor - blurred) * amount;
|
86
|
+
vec4 sharp = inputColor + clamp(inputColor - blurred, 0.0, 1.0) * amount;
|
87
87
|
|
88
88
|
// Ensure the sharp color does not go below 0 or above 1
|
89
89
|
sharp = clamp(sharp, 0.0, 1.0);
|