11import {
22 LinearEncoding ,
3+ RGBEEncoding ,
34 sRGBEncoding
45} from '../../../../build/three.module.js' ;
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';
135157ColorSpaceNode . SRGB_TO_LINEAR = 'sRGBToLinear' ;
136158ColorSpaceNode . LINEAR_TO_SRGB = 'LinearTosRGB' ;
137159
160+ ColorSpaceNode . RGBE_TO_LINEAR = 'RGBEToLinear' ;
161+ ColorSpaceNode . LINEAR_TO_RGBE = 'LinearToRGBE' ;
162+
138163ColorSpaceNode . getEncodingComponents = function ( encoding ) {
139164
140165 switch ( encoding ) {
@@ -143,6 +168,13 @@ ColorSpaceNode.getEncodingComponents = function ( encoding ) {
143168 return [ 'Linear' ] ;
144169 case sRGBEncoding :
145170 return [ 'sRGB' ] ;
171+ < << << << HEAD
172+ = === ===
173+ case RGBEEncoding :
174+ return [ 'RGBE' ] ;
175+ case GammaEncoding :
176+ return [ 'Gamma' , new ExpressionNode ( 'float( GAMMA_FACTOR )' , 'f' ) ] ;
177+ > >>> >>> parent of cee9706c1c . . . WebGLRenderer : Remove RGBEEncoding and RGBEFormat . ( #23060 )
146178
147179 }
148180
0 commit comments