Skip to content

Commit 80d4c7d

Browse files
authored
Revert "WebGLRenderer: Remove RGBEEncoding and RGBEFormat. (mrdoob#23060)" (#77)
This reverts commit cee9706.
1 parent c619917 commit 80d4c7d

23 files changed

+122
-17
lines changed

docs/api/en/constants/Textures.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ <h2>Formats</h2>
148148
THREE.RGBAIntegerFormat
149149
THREE.LuminanceFormat
150150
THREE.LuminanceAlphaFormat
151+
THREE.RGBEFormat
151152
THREE.DepthFormat
152153
THREE.DepthStencilFormat
153154
</code>
@@ -189,6 +190,8 @@ <h2>Formats</h2>
189190
The same process occurs as for the [page:constant LuminanceFormat], except that the
190191
alpha channel may have values other than *1.0*.<br /><br />
191192

193+
[page:constant RGBEFormat] is identical to [page:constant RGBAFormat].<br /><br />
194+
192195
[page:constant DepthFormat] reads each element as a single depth value, converts it to floating point, and clamps to the range [0,1].
193196
This is the default for [page:DepthTexture DepthTexture].<br /><br />
194197

@@ -533,6 +536,7 @@ <h2>Encoding</h2>
533536
<code>
534537
THREE.LinearEncoding
535538
THREE.sRGBEncoding
539+
THREE.RGBEEncoding
536540
THREE.BasicDepthPacking
537541
THREE.RGBADepthPacking
538542
</code>

docs/api/en/extras/PMREMGenerator.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ <h3>[method:WebGLRenderTarget fromEquirectangular]( [param:Texture equirectangul
4242
<p>
4343
[page:Texture equirectangular] - The equirectangular texture.<br /><br />
4444

45-
Generates a PMREM from an equirectangular texture, which can be either LDR or HDR.
45+
Generates a PMREM from an equirectangular texture, which can be either LDR (RGBFormat) or HDR (RGBEFormat).
4646
The ideal input image size is 1k (1024 x 512), as this matches best with the 256 x 256 cubemap output.
4747
</p>
4848

4949
<h3>[method:WebGLRenderTarget fromCubemap]( [param:CubeTexture cubemap] )</h3>
5050
<p>
5151
[page:CubeTexture cubemap] - The cubemap texture.<br /><br />
5252

53-
Generates a PMREM from an cubemap texture, which can be either LDR or HDR.
53+
Generates a PMREM from an cubemap texture, which can be either LDR (RGBFormat) or HDR (RGBEFormat).
5454
The ideal input cube size is 256 x 256, as this matches best with the 256 x 256 cubemap output.
5555
</p>
5656

docs/api/ko/constants/Textures.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ <h2>포맷</h2>
145145
THREE.RGBAIntegerFormat
146146
THREE.LuminanceFormat
147147
THREE.LuminanceAlphaFormat
148+
THREE.RGBEFormat
148149
THREE.DepthFormat
149150
THREE.DepthStencilFormat
150151
</code>
@@ -185,6 +186,8 @@ <h2>포맷</h2>
185186
The same process occurs as for the [page:constant LuminanceFormat]와 같은 절차가 이루어지며, 알파 채널에 *1.0* 이외의 값이 들어갈 수 있다는 점만 다릅니다.
186187
<br /><br />
187188

189+
[page:constant RGBEFormat]은 [page:constant RGBAFormat]과 동일합니다..<br /><br />
190+
188191
[page:constant DepthFormat]은 각 요소를 단일 깊이 값으로 일거들이며 부동 소수점으로 변환하고, [0,1]범위에 고정합니다.
189192
[page:DepthTexture DepthTexture]의 기본값이기도 합니다.<br /><br />
190193

@@ -527,6 +530,7 @@ <h2>인코딩</h2>
527530
<code>
528531
THREE.LinearEncoding
529532
THREE.sRGBEncoding
533+
THREE.RGBEEncoding
530534
THREE.BasicDepthPacking
531535
THREE.RGBADepthPacking
532536
</code>

docs/api/ko/extras/PMREMGenerator.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ <h1>[name]</h1>
1111

1212
<p class="desc">
1313
이 클래스는 큐브맵 환경 텍스처로부터 사전 필터링된 Mipmap Radiance Environment Map(PMREM)을 생성합니다.
14-
이를 통해 재질의 거칠기에 따라 다양한 수준의 블러를 빠르게 적용할 수 있습니다. RGBE와 같은 비선형 형식을 지원할 수 있도록 사용자 지정 보간을 수행할 수 있는 특수 CubeUV 형식으로 포장되어 있습니다.
14+
이를 통해 재질의 거칠기에 따라 다양한 수준의 블러를 빠르게 적용할 수 있습니다. RGBE와 같은 비선형 형식을 지원할 수 있도록 사용자 지정 보간을 수행할 수 있는 특수 CubeUV 형식으로 포장되어 있습니다.
1515
기존의 mipmap 체인과는 달리, LOD_MIN 수준까지만 내려가며(위), 더 높은 거칠기 수준과 연관된 동일한 LOD_MIN 해상도에서 훨씬 더 많은 필터링된 'mips'를 생성합니다.
1616
이러한 방법으로 샘플링 계산을 제한하면서 확산 조명을 부드럽게 보간하기 위한 해상도를 유지합니다.
1717
</p>
@@ -40,15 +40,15 @@ <h3>[method:WebGLRenderTarget fromEquirectangular]( [param:Texture equirectangul
4040
<p>
4141
[page:Texture equirectangular] - 등장방형 텍스쳐입니다.<br /><br />
4242

43-
LDR 또는 HDR일 수 있는 등장방형 텍스처로부터 PMREM을 생성합니다.
43+
LDR(RGBFormat) 또는 HDR(RGBEFormat)일 수 있는 등장방형 텍스처로부터 PMREM을 생성합니다.
4444
이상적인 입력 이미지 크기는 1k(1024 x 512)로, 256 x 256 큐브 맵 출력과 가장 잘 일치합니다.
4545
</p>
4646

4747
<h3>[method:WebGLRenderTarget fromCubemap]( [param:CubeTexture cubemap] )</h3>
4848
<p>
4949
[page:CubeTexture cubemap] - 큐브맵 텍스쳐입니다.<br /><br />
5050

51-
LDR 또는 HDR일 수 있는 큐브맵 텍스처로부터 PMREM을 생성합니다.
51+
LDR(RGBFormat) 또는 HDR(RGBEFormat)일 수 있는 큐브맵 텍스처로부터 PMREM을 생성합니다.
5252
이상적인 입력 이미지 크기는 1k(1024 x 512)로, 256 x 256 큐브 맵 출력과 가장 잘 일치합니다.
5353
</p>
5454

@@ -64,8 +64,8 @@ <h3>[method:undefined compileEquirectangularShader]()</h3>
6464

6565
<h3>[method:undefined dispose]()</h3>
6666
<p>
67-
PMREM 제너레이터의 내장 메모리를 폐기합니다.
68-
PMREMGenerator는 정적 클래스이므로 두 개 이상의 PMREMGenerator 개체가 필요하지 않습니다.
67+
PMREM 제너레이터의 내장 메모리를 폐기합니다.
68+
PMREMGenerator는 정적 클래스이므로 두 개 이상의 PMREMGenerator 개체가 필요하지 않습니다.
6969
이 경우 둘 중 하나에 대해 dispose()를 호출하면 다른 항목도 사용할 수 없게 됩니다.
7070
</p>
7171

docs/api/zh/constants/Textures.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ <h2>格式</h2>
138138
THREE.RGBAIntegerFormat
139139
THREE.LuminanceFormat
140140
THREE.LuminanceAlphaFormat
141+
THREE.RGBEFormat
141142
THREE.DepthFormat
142143
THREE.DepthStencilFormat
143144
</code>
@@ -175,6 +176,8 @@ <h2>格式</h2>
175176
[page:constant LuminanceAlphaFormat] 将每个元素同时作为亮度分量和Alpha分量来读取。
176177
和上面[page:constant LuminanceFormat]的处理过程是一致的,除了Alpha分量具有除了*1.0*以外的值。<br /><br />
177178

179+
[page:constant RGBEFormat] 与 [page:constant RGBAFormat] 是相同的。<br /><br />
180+
178181
[page:constant DepthFormat]将每个元素作为单独的深度值来读取,将其转换为范围限制在[0,1]区间的浮点数。
179182
它是[page:DepthTexture DepthTexture]的默认值。<br /><br />
180183

@@ -522,6 +525,7 @@ <h2>编码</h2>
522525
<code>
523526
THREE.LinearEncoding
524527
THREE.sRGBEncoding
528+
THREE.RGBEEncoding
525529
THREE.BasicDepthPacking
526530
THREE.RGBADepthPacking
527531
</code>

docs/api/zh/extras/PMREMGenerator.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ <h3>[method:WebGLRenderTarget fromEquirectangular]( [param:Texture equirectangul
4242
<p>
4343
[page:Texture equirectangular] - The equirectangular texture.<br /><br />
4444

45-
Generates a PMREM from an equirectangular texture, which can be either LDR or HDR.
45+
Generates a PMREM from an equirectangular texture, which can be either LDR (RGBFormat) or HDR (RGBEFormat).
4646
The ideal input image size is 1k (1024 x 512), as this matches best with the 256 x 256 cubemap output.
4747
</p>
4848

4949
<h3>[method:WebGLRenderTarget fromCubemap]( [param:CubeTexture cubemap] )</h3>
5050
<p>
5151
[page:CubeTexture cubemap] - The cubemap texture.<br /><br />
5252

53-
Generates a PMREM from an cubemap texture, which can be either LDR or HDR.
53+
Generates a PMREM from an cubemap texture, which can be either LDR (RGBFormat) or HDR (RGBEFormat).
5454
The ideal input cube size is 256 x 256, as this matches best with the 256 x 256 cubemap output.
5555
</p>
5656

editor/js/libs/ui.three.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class UITexture extends UISpan {
5656

5757
// assuming RGBE/Radiance HDR iamge format
5858

59-
const loader = new RGBELoader();
59+
const loader = new RGBELoader().setDataType( THREE.FloatType );
6060
loader.load( event.target.result, function ( hdrTexture ) {
6161

6262
hdrTexture.sourceFile = file.name;

examples/jsm/loaders/HDRCubeTextureLoader.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ import {
66
HalfFloatType,
77
LinearEncoding,
88
LinearFilter,
9-
Loader
9+
Loader,
10+
NearestFilter,
11+
RGBAFormat,
12+
RGBEEncoding,
13+
RGBFormat,
14+
UnsignedByteType
1015
} from 'three';
1116
import { RGBELoader } from '../loaders/RGBELoader.js';
1217

@@ -42,6 +47,15 @@ class HDRCubeTextureLoader extends Loader {
4247

4348
switch ( texture.type ) {
4449

50+
case UnsignedByteType:
51+
52+
texture.encoding = RGBEEncoding;
53+
texture.format = RGBAFormat;
54+
texture.minFilter = NearestFilter;
55+
texture.magFilter = NearestFilter;
56+
texture.generateMipmaps = false;
57+
break;
58+
4559
case FloatType:
4660

4761
texture.encoding = LinearEncoding;

examples/jsm/loaders/RGBELoader.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ import {
44
FloatType,
55
HalfFloatType,
66
LinearEncoding,
7-
LinearFilter
7+
LinearFilter,
8+
NearestFilter,
9+
RGBEEncoding,
10+
RGBEFormat,
11+
RGBFormat,
12+
UnsignedByteType
813
} from 'three';
914

1015
// https://github.com/mrdoob/three.js/issues/5552
@@ -375,6 +380,13 @@ class RGBELoader extends DataTextureLoader {
375380

376381
switch ( this.type ) {
377382

383+
case UnsignedByteType:
384+
385+
data = image_rgba_data;
386+
format = RGBEFormat; // handled as THREE.RGBAFormat in shaders
387+
type = UnsignedByteType;
388+
break;
389+
378390
case FloatType:
379391

380392
numElements = image_rgba_data.length / 4;
@@ -443,6 +455,15 @@ class RGBELoader extends DataTextureLoader {
443455

444456
switch ( texture.type ) {
445457

458+
case UnsignedByteType:
459+
460+
texture.encoding = RGBEEncoding;
461+
texture.minFilter = NearestFilter;
462+
texture.magFilter = NearestFilter;
463+
texture.generateMipmaps = false;
464+
texture.flipY = true;
465+
break;
466+
446467
case FloatType:
447468

448469
texture.encoding = LinearEncoding;

examples/jsm/nodes/utils/ColorSpaceNode.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
LinearEncoding,
3+
RGBEEncoding,
34
sRGBEncoding
45
} from 'three';
56

@@ -122,10 +123,31 @@ ColorSpaceNode.Nodes = ( function () {
122123
}`
123124
);
124125

126+
const RGBEToLinear = new FunctionNode( /* glsl */`
127+
vec4 RGBEToLinear( in vec4 value ) {
128+
129+
return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );
130+
131+
}`
132+
);
133+
134+
const LinearToRGBE = new FunctionNode( /* glsl */`
135+
vec4 LinearToRGBE( in vec4 value ) {
136+
137+
float maxComponent = max( max( value.r, value.g ), value.b );
138+
float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );
139+
return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );
140+
141+
}`
142+
);
143+
144+
125145
return {
126146
LinearToLinear: LinearToLinear,
127147
sRGBToLinear: sRGBToLinear,
128-
LinearTosRGB: LinearTosRGB
148+
LinearTosRGB: LinearTosRGB,
149+
RGBEToLinear: RGBEToLinear,
150+
LinearToRGBE: LinearToRGBE
129151
};
130152

131153
} )();
@@ -135,6 +157,9 @@ ColorSpaceNode.LINEAR_TO_LINEAR = 'LinearToLinear';
135157
ColorSpaceNode.SRGB_TO_LINEAR = 'sRGBToLinear';
136158
ColorSpaceNode.LINEAR_TO_SRGB = 'LinearTosRGB';
137159

160+
ColorSpaceNode.RGBE_TO_LINEAR = 'RGBEToLinear';
161+
ColorSpaceNode.LINEAR_TO_RGBE = 'LinearToRGBE';
162+
138163
ColorSpaceNode.getEncodingComponents = function ( encoding ) {
139164

140165
switch ( encoding ) {
@@ -143,6 +168,8 @@ ColorSpaceNode.getEncodingComponents = function ( encoding ) {
143168
return [ 'Linear' ];
144169
case sRGBEncoding:
145170
return [ 'sRGB' ];
171+
case RGBEEncoding:
172+
return [ 'RGBE' ];
146173

147174
}
148175

0 commit comments

Comments
 (0)