feat: adjust raw black point and use luminance-based curve application
This commit is contained in:
1 parent
f480880355
commit
cab2498d5a
2 files changed
+10
-11
No files matched your search
@@ -2254,16 +2254,17 @@ class RawDemosaicProcessor {
|
||||
rawBlackPointCorrection: Float,
|
||||
rawWhitePointCorrection: Float
|
||||
): Pair<FloatArray, FloatArray> {
|
||||
val fixedRawBlackPoint = (rawBlackPointCorrection + 0.004f).coerceAtMost(1f)
|
||||
if (metadata.cfaPattern == RawMetadata.CFA_LINEAR_RGB) {
|
||||
val encodedMax = 65535f
|
||||
val blackLevel = FloatArray(3) { (encodedMax * rawBlackPointCorrection).coerceAtLeast(0f) }
|
||||
val blackLevel = FloatArray(3) { (encodedMax * fixedRawBlackPoint).coerceAtLeast(0f) }
|
||||
val whiteBase = encodedMax * (1f + rawWhitePointCorrection)
|
||||
val whiteLevel = FloatArray(3) { channel -> maxOf(whiteBase, blackLevel[channel] + 1f) }
|
||||
return blackLevel to whiteLevel
|
||||
}
|
||||
|
||||
val sensorRange = metadata.whiteLevel - metadata.blackLevel.average().toFloat()
|
||||
val blackPointOffset = sensorRange * rawBlackPointCorrection
|
||||
val blackPointOffset = sensorRange * fixedRawBlackPoint
|
||||
val whitePointOffset = sensorRange * rawWhitePointCorrection
|
||||
val blackLevel = FloatArray(3) { channel ->
|
||||
val sourceIndex = channelToCfaChannelIndex(channel)
|
||||
|
||||
@@ -145,6 +145,10 @@ object RawShaders {
|
||||
uniform ivec3 uDcpLookTableDivisions;
|
||||
uniform int uDcpHueSatEncoding;
|
||||
uniform int uDcpLookTableEncoding;
|
||||
|
||||
float luminance(vec3 color) {
|
||||
return max(dot(color, vec3(0.2126, 0.7152, 0.0722)), 1e-4);
|
||||
}
|
||||
|
||||
float sampleCurve(float value) {
|
||||
if (!uCurveEnabled || uCurveSize <= 1.0) {
|
||||
@@ -156,11 +160,9 @@ object RawShaders {
|
||||
}
|
||||
|
||||
vec3 applyCurve(vec3 color) {
|
||||
return vec3(
|
||||
sampleCurve(color.r),
|
||||
sampleCurve(color.g),
|
||||
sampleCurve(color.b)
|
||||
);
|
||||
float luma = luminance(color);
|
||||
float scale = sampleCurve(luma) / max(luma, 0.00001);
|
||||
return clamp(color * scale, 0.0, 1.0);
|
||||
}
|
||||
|
||||
vec3 linearToSrgb(vec3 color) {
|
||||
@@ -174,10 +176,6 @@ object RawShaders {
|
||||
useHigh.b ? high.b : low.b
|
||||
);
|
||||
}
|
||||
|
||||
float luminance(vec3 color) {
|
||||
return max(dot(color, vec3(0.2126, 0.7152, 0.0722)), 1e-4);
|
||||
}
|
||||
|
||||
float encodeValue(float value, int encoding) {
|
||||
value = clamp(value, 0.0, 1.0);
|
||||
|
||||
Reference in new issue
Block a user