Skip to content

Commit

Permalink
Revert "WebGLRenderer: Remove RGBEEncoding and RGBEFormat. (mrdoob#23060
Browse files Browse the repository at this point in the history
)" (oppenfuture#77)

This reverts commit cee9706.
  • Loading branch information
chubei-oppen authored Mar 16, 2022
1 parent c619917 commit 80d4c7d
Show file tree
Hide file tree
Showing 23 changed files with 122 additions and 17 deletions.
4 changes: 4 additions & 0 deletions docs/api/en/constants/Textures.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ <h2>Formats</h2>
THREE.RGBAIntegerFormat
THREE.LuminanceFormat
THREE.LuminanceAlphaFormat
THREE.RGBEFormat
THREE.DepthFormat
THREE.DepthStencilFormat
</code>
Expand Down Expand Up @@ -189,6 +190,8 @@ <h2>Formats</h2>
The same process occurs as for the [page:constant LuminanceFormat], except that the
alpha channel may have values other than *1.0*.<br /><br />

[page:constant RGBEFormat] is identical to [page:constant RGBAFormat].<br /><br />

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

Expand Down Expand Up @@ -533,6 +536,7 @@ <h2>Encoding</h2>
<code>
THREE.LinearEncoding
THREE.sRGBEncoding
THREE.RGBEEncoding
THREE.BasicDepthPacking
THREE.RGBADepthPacking
</code>
Expand Down
4 changes: 2 additions & 2 deletions docs/api/en/extras/PMREMGenerator.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ <h3>[method:WebGLRenderTarget fromEquirectangular]( [param:Texture equirectangul
<p>
[page:Texture equirectangular] - The equirectangular texture.<br /><br />

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

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

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

Expand Down
4 changes: 4 additions & 0 deletions docs/api/ko/constants/Textures.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ <h2>포맷</h2>
THREE.RGBAIntegerFormat
THREE.LuminanceFormat
THREE.LuminanceAlphaFormat
THREE.RGBEFormat
THREE.DepthFormat
THREE.DepthStencilFormat
</code>
Expand Down Expand Up @@ -185,6 +186,8 @@ <h2>포맷</h2>
The same process occurs as for the [page:constant LuminanceFormat]와 같은 절차가 이루어지며, 알파 채널에 *1.0* 이외의 값이 들어갈 수 있다는 점만 다릅니다.
<br /><br />

[page:constant RGBEFormat]은 [page:constant RGBAFormat]과 동일합니다..<br /><br />

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

Expand Down Expand Up @@ -527,6 +530,7 @@ <h2>인코딩</h2>
<code>
THREE.LinearEncoding
THREE.sRGBEncoding
THREE.RGBEEncoding
THREE.BasicDepthPacking
THREE.RGBADepthPacking
</code>
Expand Down
10 changes: 5 additions & 5 deletions docs/api/ko/extras/PMREMGenerator.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h1>[name]</h1>

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

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

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

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

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

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

Expand Down
4 changes: 4 additions & 0 deletions docs/api/zh/constants/Textures.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ <h2>格式</h2>
THREE.RGBAIntegerFormat
THREE.LuminanceFormat
THREE.LuminanceAlphaFormat
THREE.RGBEFormat
THREE.DepthFormat
THREE.DepthStencilFormat
</code>
Expand Down Expand Up @@ -175,6 +176,8 @@ <h2>格式</h2>
[page:constant LuminanceAlphaFormat] 将每个元素同时作为亮度分量和Alpha分量来读取。
和上面[page:constant LuminanceFormat]的处理过程是一致的,除了Alpha分量具有除了*1.0*以外的值。<br /><br />

[page:constant RGBEFormat] 与 [page:constant RGBAFormat] 是相同的。<br /><br />

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

Expand Down Expand Up @@ -522,6 +525,7 @@ <h2>编码</h2>
<code>
THREE.LinearEncoding
THREE.sRGBEncoding
THREE.RGBEEncoding
THREE.BasicDepthPacking
THREE.RGBADepthPacking
</code>
Expand Down
4 changes: 2 additions & 2 deletions docs/api/zh/extras/PMREMGenerator.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ <h3>[method:WebGLRenderTarget fromEquirectangular]( [param:Texture equirectangul
<p>
[page:Texture equirectangular] - The equirectangular texture.<br /><br />

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion editor/js/libs/ui.three.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class UITexture extends UISpan {

// assuming RGBE/Radiance HDR iamge format

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

hdrTexture.sourceFile = file.name;
Expand Down
16 changes: 15 additions & 1 deletion examples/jsm/loaders/HDRCubeTextureLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import {
HalfFloatType,
LinearEncoding,
LinearFilter,
Loader
Loader,
NearestFilter,
RGBAFormat,
RGBEEncoding,
RGBFormat,
UnsignedByteType
} from 'three';
import { RGBELoader } from '../loaders/RGBELoader.js';

Expand Down Expand Up @@ -42,6 +47,15 @@ class HDRCubeTextureLoader extends Loader {

switch ( texture.type ) {

case UnsignedByteType:

texture.encoding = RGBEEncoding;
texture.format = RGBAFormat;
texture.minFilter = NearestFilter;
texture.magFilter = NearestFilter;
texture.generateMipmaps = false;
break;

case FloatType:

texture.encoding = LinearEncoding;
Expand Down
23 changes: 22 additions & 1 deletion examples/jsm/loaders/RGBELoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import {
FloatType,
HalfFloatType,
LinearEncoding,
LinearFilter
LinearFilter,
NearestFilter,
RGBEEncoding,
RGBEFormat,
RGBFormat,
UnsignedByteType
} from 'three';

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

switch ( this.type ) {

case UnsignedByteType:

data = image_rgba_data;
format = RGBEFormat; // handled as THREE.RGBAFormat in shaders
type = UnsignedByteType;
break;

case FloatType:

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

switch ( texture.type ) {

case UnsignedByteType:

texture.encoding = RGBEEncoding;
texture.minFilter = NearestFilter;
texture.magFilter = NearestFilter;
texture.generateMipmaps = false;
texture.flipY = true;
break;

case FloatType:

texture.encoding = LinearEncoding;
Expand Down
29 changes: 28 additions & 1 deletion examples/jsm/nodes/utils/ColorSpaceNode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
LinearEncoding,
RGBEEncoding,
sRGBEncoding
} from 'three';

Expand Down Expand Up @@ -122,10 +123,31 @@ ColorSpaceNode.Nodes = ( function () {
}`
);

const RGBEToLinear = new FunctionNode( /* glsl */`
vec4 RGBEToLinear( in vec4 value ) {
return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );
}`
);

const LinearToRGBE = new FunctionNode( /* glsl */`
vec4 LinearToRGBE( in vec4 value ) {
float maxComponent = max( max( value.r, value.g ), value.b );
float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );
return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );
}`
);


return {
LinearToLinear: LinearToLinear,
sRGBToLinear: sRGBToLinear,
LinearTosRGB: LinearTosRGB
LinearTosRGB: LinearTosRGB,
RGBEToLinear: RGBEToLinear,
LinearToRGBE: LinearToRGBE
};

} )();
Expand All @@ -135,6 +157,9 @@ ColorSpaceNode.LINEAR_TO_LINEAR = 'LinearToLinear';
ColorSpaceNode.SRGB_TO_LINEAR = 'sRGBToLinear';
ColorSpaceNode.LINEAR_TO_SRGB = 'LinearTosRGB';

ColorSpaceNode.RGBE_TO_LINEAR = 'RGBEToLinear';
ColorSpaceNode.LINEAR_TO_RGBE = 'LinearToRGBE';

ColorSpaceNode.getEncodingComponents = function ( encoding ) {

switch ( encoding ) {
Expand All @@ -143,6 +168,8 @@ ColorSpaceNode.getEncodingComponents = function ( encoding ) {
return [ 'Linear' ];
case sRGBEncoding:
return [ 'sRGB' ];
case RGBEEncoding:
return [ 'RGBE' ];

}

Expand Down
1 change: 1 addition & 0 deletions examples/misc_controls_arcball.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
render();

new RGBELoader()
.setDataType( THREE.UnsignedByteType )
.setPath( 'textures/equirectangular/' )
.load( 'venice_sunset_1k.hdr', function ( hdrEquirect ) {

Expand Down
1 change: 1 addition & 0 deletions examples/webgl_loader_texture_hdr.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
camera = new THREE.OrthographicCamera( - aspect, aspect, 1, - 1, 0, 1 );

new RGBELoader()
.setDataType( THREE.UnsignedByteType ) // alt: FloatType, HalfFloatType
.load( 'textures/memorial.hdr', function ( texture, textureData ) {

//console.log( textureData );
Expand Down
1 change: 1 addition & 0 deletions examples/webgl_materials_envmaps_hdr.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
const hdrUrls = [ 'px.hdr', 'nx.hdr', 'py.hdr', 'ny.hdr', 'pz.hdr', 'nz.hdr' ];
hdrCubeMap = new HDRCubeTextureLoader()
.setPath( './textures/cube/pisaHDR/' )
.setDataType( THREE.UnsignedByteType )
.load( hdrUrls, function () {

hdrCubeRenderTarget = pmremGenerator.fromCubemap( hdrCubeMap );
Expand Down
1 change: 1 addition & 0 deletions examples/webgl_materials_envmaps_hdr_nodes.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
const hdrUrls = [ 'px.hdr', 'nx.hdr', 'py.hdr', 'ny.hdr', 'pz.hdr', 'nz.hdr' ];
hdrCubeMap = new HDRCubeTextureLoader()
.setPath( './textures/cube/pisaHDR/' )
.setDataType( THREE.UnsignedByteType )
.load( hdrUrls, function () {

hdrCubeRenderTarget = pmremGenerator.fromCubemap( hdrCubeMap );
Expand Down
1 change: 1 addition & 0 deletions examples/webgl_materials_envmaps_pmrem_nodes.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
const hdrUrls = [ 'px.hdr', 'nx.hdr', 'py.hdr', 'ny.hdr', 'pz.hdr', 'nz.hdr' ];
hdrCubeMap = new HDRCubeTextureLoader()
.setPath( './textures/cube/pisaHDR/' )
.setDataType( THREE.UnsignedByteType )
.load( hdrUrls, function () {

hdrCubeRenderTarget = pmremGenerator.fromCubemap( hdrCubeMap );
Expand Down
1 change: 1 addition & 0 deletions examples/webgl_materials_standard_nodes.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@

const filename = environments[ name ].filename;
new RGBELoader()
.setDataType( THREE.UnsignedByteType )
.setPath( 'textures/equirectangular/' )
.load( filename, function ( hdrEquirect ) {

Expand Down
1 change: 1 addition & 0 deletions examples/webgl_pmrem_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@

let radianceMap = null;
new RGBELoader()
.setDataType( THREE.UnsignedByteType )
// .setDataType( THREE.FloatType )
.setPath( 'textures/equirectangular/' )
.load( 'spot1Lux.hdr', function ( texture ) {
Expand Down
1 change: 1 addition & 0 deletions examples/webxr_ar_lighting.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
//

new RGBELoader()
.setDataType( THREE.UnsignedByteType )
.setPath( 'textures/equirectangular/' )
.load( 'royal_esplanade_1k.hdr', function ( texture ) {

Expand Down
2 changes: 2 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export const RGBFormat = 1022;
export const RGBAFormat = 1023;
export const LuminanceFormat = 1024;
export const LuminanceAlphaFormat = 1025;
export const RGBEFormat = RGBAFormat;
export const DepthFormat = 1026;
export const DepthStencilFormat = 1027;
export const RedFormat = 1028;
Expand Down Expand Up @@ -140,6 +141,7 @@ export const TriangleStripDrawMode = 1;
export const TriangleFanDrawMode = 2;
export const LinearEncoding = 3000;
export const sRGBEncoding = 3001;
export const RGBEEncoding = 3002;
export const BasicDepthPacking = 3200;
export const RGBADepthPacking = 3201;
export const TangentSpaceNormalMap = 0;
Expand Down
Loading

0 comments on commit 80d4c7d

Please sign in to comment.