首页 > 其他分享 >luminance

luminance

时间:2024-02-02 10:12:38浏览次数:24  
标签:xyYCol luminance color float vec3 xyzCol





-------------------------------


// Approximates the brightness of a RGB value. 
float luminance( vec3 color ) { 
 return dot(lum, color);
}


---------------------------


int size = width * height;
std::vector<GLfloat> texData(size*3);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, hdrTex);
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_FLOAT, texData.data());
float sum = 0.0f;
for( int i = 0; i < size; i++ ) {
 float lum = computeLum(texData[i*3+0], texData[i*3+1], texData[i*3+2]);
 sum += logf( lum + 0.00001f );
}
float logAve = expf( sum / size );


-----------------------------


// Retrieve high-res color from texture 
vec4 color = texture( HdrTex, TexCoord ); 
   
// Convert to XYZ 
vec3 xyzCol = rgb2xyz * vec3(color); 
 
// Convert to xyY 
float xyzSum = xyzCol.x + xyzCol.y + xyzCol.z; 
vec3 xyYCol = vec3(0.0); 
if( xyzSum > 0.0 ) // Avoid divide by zero 
  xyYCol = vec3( xyzCol.x / xyzSum, 
         xyzCol.y / xyzSum, xyzCol.y); 
 
// Apply the tone mapping operation to the luminance 
// (xyYCol.z or xyzCol.y) 
float L = (Exposure * xyYCol.z) / AveLum; 
L = (L * ( 1 + L / (White * White) )) / ( 1 + L ); 
// Using the new luminance, convert back to XYZ 
if( xyYCol.y > 0.0 ) { 
 xyzCol.x = (L * xyYCol.x) / (xyYCol.y); 
 xyzCol.y = L; 
 xyzCol.z = (L * (1 - xyYCol.x - xyYCol.y))/xyYCol.y; 
} 
 
// Convert back to RGB and send to output buffer 
FragColor = vec4( xyz2rgb * xyzCol, 1.0);

标签:xyYCol,luminance,color,float,vec3,xyzCol
From: https://www.cnblogs.com/gispathfinder/p/18002615

相关文章

  • IfcIlluminanceMeasure
    IfcIlluminanceMeasure类型定义IfcIlluminanceMeasure是照度的度量。通常以勒克斯(lx,Lumen/m2=斯特拉迪安烛光/m2)为单位测量。类型:REALIFC2x中的新类型。   EXP......
  • IfcIlluminanceMeasure
    IfcIlluminanceMeasure类型定义IfcIlluminanceMeasure是照度的度量。通常以勒克斯(lx,Lumen/m2=斯特拉迪安烛光/m2)为单位测量。类型:REALIFC2x中的新类型。 EXPRESSS......