Skip to content

Commit 9db09da

Browse files
committed
Encode normals
1 parent 364cf7c commit 9db09da

File tree

4 files changed

+6
-13
lines changed

4 files changed

+6
-13
lines changed

src/passes/GeometryPass.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
PerspectiveCamera,
1414
RGBAFormat,
1515
RGBFormat,
16+
RGFormat,
1617
SRGBColorSpace,
1718
Scene,
1819
TextureDataType,
@@ -301,7 +302,7 @@ export class GeometryPass extends Pass implements GeometryPassOptions, Selective
301302
minFilter: NearestFilter,
302303
magFilter: NearestFilter,
303304
type: HalfFloatType,
304-
format: RGBAFormat
305+
format: RGFormat
305306
});
306307

307308
textureConfigs.set(GBuffer.ORM, {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#ifdef out_Normal
22

3-
out_Normal = vec4(normal, 1.0);
3+
out_Normal.xy = pp_encodeNormal(normal);
44

55
#endif
Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Reads a normal vector from a given buffer. Supports octahedron encoding and decoding.
2+
* Reads a normal vector from a given buffer.
33
*
44
* @param normalBuffer - The normal texture.
55
* @param uv - The texture coordinates.
@@ -8,14 +8,6 @@
88

99
vec3 readNormal(mediump sampler2D normalBuffer, const in vec2 uv) {
1010

11-
#ifdef PP_NORMAL_VELOCITY
12-
13-
return pp_decodeNormal(texture(normalBuffer, uv).xy);
14-
15-
#else
16-
17-
return texture(normalBuffer, uv).xyz;
18-
19-
#endif
11+
return pp_decodeNormal(texture(normalBuffer, uv).xy);
2012

2113
}

src/utils/ClearValues.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class ClearValues extends EventDispatcher<BaseEventMap> {
4141
this._alpha = null;
4242

4343
const gBuffer = new ObservableMap<string, Iterable<GLfloat>>([
44-
[GBuffer.NORMAL, [0.0, 0.0, 1.0, 0.0]],
44+
[GBuffer.NORMAL, [0.0, 0.0]],
4545
[GBuffer.ORM, [1.0, 0.0, 0.0, 1.0]],
4646
[GBuffer.EMISSION, [0.0, 0.0, 0.0, 1.0]]
4747
]);

0 commit comments

Comments
 (0)