feat: raw color engine arri
This commit is contained in:
1 parent
22587e9190
commit
0a1e1f8fac
10 files changed
+253
-41
No files matched your search
Binary file not shown.
@@ -6,37 +6,28 @@ import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import java.nio.FloatBuffer
|
||||
|
||||
data class AgxLut(
|
||||
data class RawEngineLut(
|
||||
val name: String,
|
||||
val sourceKey: String,
|
||||
val size: Int,
|
||||
val rgbaFloatBuffer: FloatBuffer
|
||||
)
|
||||
|
||||
object AgXColorEngine {
|
||||
private const val TAG = "AgXColorEngine"
|
||||
private const val BASE_SRGB_ASSET = "agx/AgX_Base_sRGB.plut"
|
||||
typealias AgxLut = RawEngineLut
|
||||
typealias ArriLut = RawEngineLut
|
||||
|
||||
object RawEngineLutLoader {
|
||||
private const val MAGIC_PLUT = 0x54554C50
|
||||
private const val DATA_TYPE_UINT8 = 0
|
||||
private const val DATA_TYPE_UINT16 = 1
|
||||
|
||||
@Volatile
|
||||
private var cachedBaseSrgb: AgxLut? = null
|
||||
|
||||
fun loadBaseSrgbLut(context: Context): AgxLut? {
|
||||
cachedBaseSrgb?.let { return it }
|
||||
return synchronized(this) {
|
||||
cachedBaseSrgb ?: loadPlut(context, BASE_SRGB_ASSET)?.also { cachedBaseSrgb = it }
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadPlut(context: Context, assetPath: String): AgxLut? {
|
||||
fun loadPlut(context: Context, assetPath: String, tag: String): RawEngineLut? {
|
||||
val startTime = System.currentTimeMillis()
|
||||
return try {
|
||||
val bytes = context.assets.open(assetPath).use { it.readBytes() }
|
||||
val buffer = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN)
|
||||
if (buffer.remaining() < 16) {
|
||||
PLog.e(TAG, "PLUT $assetPath is too short: ${bytes.size} bytes")
|
||||
PLog.e(tag, "PLUT $assetPath is too short: ${bytes.size} bytes")
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -46,8 +37,8 @@ object AgXColorEngine {
|
||||
val dataType = buffer.int
|
||||
if (magic != MAGIC_PLUT || size <= 1 || dataType !in setOf(DATA_TYPE_UINT8, DATA_TYPE_UINT16)) {
|
||||
PLog.e(
|
||||
TAG,
|
||||
"Invalid AgX PLUT $assetPath: magic=$magic version=$version size=$size dataType=$dataType"
|
||||
tag,
|
||||
"Invalid PLUT $assetPath: magic=$magic version=$version size=$size dataType=$dataType"
|
||||
)
|
||||
return null
|
||||
}
|
||||
@@ -63,7 +54,7 @@ object AgXColorEngine {
|
||||
val componentCount = texelCount * 3
|
||||
val payloadBytes = componentCount * if (dataType == DATA_TYPE_UINT16) 2 else 1
|
||||
if (buffer.remaining() < payloadBytes) {
|
||||
PLog.e(TAG, "AgX PLUT $assetPath payload too short: remaining=${buffer.remaining()} expected=$payloadBytes")
|
||||
PLog.e(tag, "PLUT $assetPath payload too short: remaining=${buffer.remaining()} expected=$payloadBytes")
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -81,18 +72,18 @@ object AgXColorEngine {
|
||||
uploadBuffer.position(0)
|
||||
|
||||
PLog.d(
|
||||
TAG,
|
||||
"Loaded AgX PLUT ${assetPath.substringAfterLast('/')} ($size^3) in " +
|
||||
tag,
|
||||
"Loaded PLUT ${assetPath.substringAfterLast('/')} ($size^3) in " +
|
||||
"${System.currentTimeMillis() - startTime}ms"
|
||||
)
|
||||
AgxLut(
|
||||
RawEngineLut(
|
||||
name = assetPath.substringAfterLast('/').substringBeforeLast('.'),
|
||||
sourceKey = "$assetPath:$version:$dataType:$size:$payloadBytes",
|
||||
size = size,
|
||||
rgbaFloatBuffer = uploadBuffer.apply { position(0) }
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
PLog.e(TAG, "Failed to load AgX PLUT from $assetPath", e)
|
||||
PLog.e(tag, "Failed to load PLUT from $assetPath", e)
|
||||
null
|
||||
}
|
||||
}
|
||||
@@ -105,3 +96,19 @@ object AgXColorEngine {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object AgXColorEngine {
|
||||
private const val TAG = "AgXColorEngine"
|
||||
private const val BASE_SRGB_ASSET = "agx/AgX_Base_sRGB.plut"
|
||||
|
||||
@Volatile
|
||||
private var cachedBaseSrgb: AgxLut? = null
|
||||
|
||||
fun loadBaseSrgbLut(context: Context): AgxLut? {
|
||||
cachedBaseSrgb?.let { return it }
|
||||
return synchronized(this) {
|
||||
cachedBaseSrgb ?: RawEngineLutLoader.loadPlut(context, BASE_SRGB_ASSET, TAG)
|
||||
?.also { cachedBaseSrgb = it }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.hinnka.mycamera.raw
|
||||
|
||||
import android.content.Context
|
||||
|
||||
object ArriColorEngine {
|
||||
private const val TAG = "ArriColorEngine"
|
||||
private const val LOGC4_TO_GAMMA24_REC709_ASSET =
|
||||
"arri/ARRI_LogC4-to-Gamma24_Rec709-D65_v1_65.plut"
|
||||
|
||||
@Volatile
|
||||
private var cachedLogC4ToGamma24Rec709: ArriLut? = null
|
||||
|
||||
fun loadLogC4ToGamma24Rec709Lut(context: Context): ArriLut? {
|
||||
cachedLogC4ToGamma24Rec709?.let { return it }
|
||||
return synchronized(this) {
|
||||
cachedLogC4ToGamma24Rec709
|
||||
?: RawEngineLutLoader.loadPlut(context, LOGC4_TO_GAMMA24_REC709_ASSET, TAG)
|
||||
?.also { cachedLogC4ToGamma24Rec709 = it }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,13 +28,21 @@ enum class RawColorEngine(
|
||||
meteringCompensationEv = RAW_COLOR_ENGINE_METERING_COMPENSATION_EV,
|
||||
exposureCompensationDomain = RawExposureCompensationDomain.Linear
|
||||
),
|
||||
ARRI(
|
||||
shaderId = 3,
|
||||
workingColorSpace = ColorSpace.ARRI4,
|
||||
defaultExposureCompensationEv = RAW_COLOR_ENGINE_METERING_COMPENSATION_EV,
|
||||
meteringCompensationEv = RAW_COLOR_ENGINE_METERING_COMPENSATION_EV,
|
||||
exposureCompensationDomain = RawExposureCompensationDomain.Linear
|
||||
),
|
||||
SpectralFilm(
|
||||
shaderId = 2,
|
||||
workingColorSpace = ColorSpace.ProPhoto,
|
||||
defaultExposureCompensationEv = RAW_COLOR_ENGINE_METERING_COMPENSATION_EV,
|
||||
meteringCompensationEv = RAW_COLOR_ENGINE_METERING_COMPENSATION_EV,
|
||||
exposureCompensationDomain = RawExposureCompensationDomain.Linear
|
||||
);
|
||||
),
|
||||
;
|
||||
|
||||
companion object {
|
||||
fun fromPersistedName(value: String?): RawColorEngine {
|
||||
|
||||
@@ -16,6 +16,7 @@ import android.opengl.GLUtils
|
||||
import android.util.Half
|
||||
import androidx.core.graphics.createBitmap
|
||||
import com.hinnka.mycamera.camera.AspectRatio
|
||||
import com.hinnka.mycamera.color.TransferCurve
|
||||
import com.hinnka.mycamera.data.ContentRepository
|
||||
import com.hinnka.mycamera.lut.ChromaDenoiseShaders
|
||||
import com.hinnka.mycamera.lut.ShadowsHighlightsShader
|
||||
@@ -175,6 +176,7 @@ class RawDemosaicProcessor {
|
||||
private const val RAW_AE_BASE_STATS_BINDING = 1
|
||||
private const val RAW_AE_TONE_STATS_BINDING = 0
|
||||
private const val AGX_BASE_SRGB_TEXTURE_UNIT = 7
|
||||
private const val ARRI_LOGC4_LUT_TEXTURE_UNIT = 8
|
||||
|
||||
private val BRADFORD_D65_TO_D50 = floatArrayOf(
|
||||
1.0478112f, 0.0228866f, -0.0501270f,
|
||||
@@ -271,6 +273,8 @@ class RawDemosaicProcessor {
|
||||
private var spectralFilmTextureKey: String? = null
|
||||
private var agxLutTextureId = 0
|
||||
private var agxLutTextureKey: String? = null
|
||||
private var arriLutTextureId = 0
|
||||
private var arriLutTextureKey: String? = null
|
||||
private var dummyDcp3DTextureId = 0
|
||||
private var dummyDcpToneCurveTextureId = 0
|
||||
|
||||
@@ -678,12 +682,23 @@ class RawDemosaicProcessor {
|
||||
} else {
|
||||
null
|
||||
}
|
||||
val arriLut =
|
||||
if (requestedColorEngine == RawColorEngine.ARRI) {
|
||||
ArriColorEngine.loadLogC4ToGamma24Rec709Lut(context)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
val colorEngine = when {
|
||||
requestedColorEngine == RawColorEngine.AgX && agxLut == null -> {
|
||||
PLog.w(TAG, "AgX LUT unavailable, falling back to AdobeCurve")
|
||||
RawColorEngine.AdobeCurve
|
||||
}
|
||||
|
||||
requestedColorEngine == RawColorEngine.ARRI && arriLut == null -> {
|
||||
PLog.w(TAG, "ARRI LUT unavailable, falling back to AdobeCurve")
|
||||
RawColorEngine.AdobeCurve
|
||||
}
|
||||
|
||||
requestedColorEngine == RawColorEngine.SpectralFilm && spectralFilmLut == null -> {
|
||||
PLog.w(TAG, "SpectralFilm LUT unavailable, falling back to AdobeCurve")
|
||||
RawColorEngine.AdobeCurve
|
||||
@@ -1167,7 +1182,9 @@ class RawDemosaicProcessor {
|
||||
dcpRenderPlan = resolvedDcpRenderPlan,
|
||||
spectralFilmLut = spectralFilmLut,
|
||||
agxLut = agxLut,
|
||||
arriLut = arriLut,
|
||||
colorEngine = colorEngine,
|
||||
workingColorSpace = rawWorkingColorSpace,
|
||||
shadowsHighlightsParams = shadowsHighlightsParams
|
||||
)
|
||||
PLog.d(TAG, "Combined Pass took: ${System.currentTimeMillis() - combinedStart}ms")
|
||||
@@ -3736,6 +3753,93 @@ class RawDemosaicProcessor {
|
||||
checkGlError("bindAgxCombinedResource")
|
||||
}
|
||||
|
||||
private fun uploadArriTexture(lut: ArriLut): Int {
|
||||
val key = "${lut.sourceKey}:${lut.rgbaFloatBuffer.capacity()}"
|
||||
if (arriLutTextureId == 0) {
|
||||
val textures = IntArray(1)
|
||||
GLES30.glGenTextures(1, textures, 0)
|
||||
arriLutTextureId = textures[0]
|
||||
arriLutTextureKey = null
|
||||
}
|
||||
if (arriLutTextureKey == key) {
|
||||
return arriLutTextureId
|
||||
}
|
||||
|
||||
val buffer = lut.rgbaFloatBuffer.duplicate().apply { position(0) }
|
||||
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_3D, arriLutTextureId)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_3D, GLES30.GL_TEXTURE_MIN_FILTER, GLES30.GL_NEAREST)
|
||||
GLES30.glTexParameteri(GLES30.GL_TEXTURE_3D, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_NEAREST)
|
||||
GLES30.glTexParameteri(
|
||||
GLES30.GL_TEXTURE_3D,
|
||||
GLES30.GL_TEXTURE_WRAP_S,
|
||||
GLES30.GL_CLAMP_TO_EDGE
|
||||
)
|
||||
GLES30.glTexParameteri(
|
||||
GLES30.GL_TEXTURE_3D,
|
||||
GLES30.GL_TEXTURE_WRAP_T,
|
||||
GLES30.GL_CLAMP_TO_EDGE
|
||||
)
|
||||
GLES30.glTexParameteri(
|
||||
GLES30.GL_TEXTURE_3D,
|
||||
GLES30.GL_TEXTURE_WRAP_R,
|
||||
GLES30.GL_CLAMP_TO_EDGE
|
||||
)
|
||||
GLES30.glTexImage3D(
|
||||
GLES30.GL_TEXTURE_3D,
|
||||
0,
|
||||
GLES30.GL_RGBA16F,
|
||||
lut.size,
|
||||
lut.size,
|
||||
lut.size,
|
||||
0,
|
||||
GLES30.GL_RGBA,
|
||||
GLES30.GL_FLOAT,
|
||||
buffer
|
||||
)
|
||||
arriLutTextureKey = key
|
||||
PLog.d(TAG, "Uploaded ARRI LUT: ${lut.name}, size=${lut.size}")
|
||||
checkGlError("uploadArriTexture")
|
||||
return arriLutTextureId
|
||||
}
|
||||
|
||||
private fun bindArriCombinedResource(arriLut: ArriLut?) {
|
||||
GLES30.glUniform1i(
|
||||
GLES30.glGetUniformLocation(combinedProgram, "uArriLogC4LutTexture"),
|
||||
ARRI_LOGC4_LUT_TEXTURE_UNIT
|
||||
)
|
||||
GLES30.glUniform1i(
|
||||
GLES30.glGetUniformLocation(combinedProgram, "uArriLutSize"),
|
||||
arriLut?.size ?: 1
|
||||
)
|
||||
bindLogC4Uniforms()
|
||||
GLES30.glActiveTexture(GLES30.GL_TEXTURE0 + ARRI_LOGC4_LUT_TEXTURE_UNIT)
|
||||
if (arriLut != null) {
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_3D, uploadArriTexture(arriLut))
|
||||
} else {
|
||||
GLES30.glBindTexture(GLES30.GL_TEXTURE_3D, ensureDummyDcp3DTexture())
|
||||
}
|
||||
checkGlError("bindArriCombinedResource")
|
||||
}
|
||||
|
||||
private fun bindLogC4Uniforms() {
|
||||
val logC4 = TransferCurve.LOGC4
|
||||
GLES30.glUniform4f(
|
||||
GLES30.glGetUniformLocation(combinedProgram, "uLogC4Params0"),
|
||||
logC4.a,
|
||||
logC4.b,
|
||||
logC4.c,
|
||||
logC4.d
|
||||
)
|
||||
GLES30.glUniform4f(
|
||||
GLES30.glGetUniformLocation(combinedProgram, "uLogC4Params1"),
|
||||
logC4.e,
|
||||
logC4.f,
|
||||
logC4.cut1,
|
||||
logC4.cut2
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Combined Processing Pass: ToneMap + LUT + Sharpening
|
||||
*/
|
||||
@@ -3745,13 +3849,15 @@ class RawDemosaicProcessor {
|
||||
dcpRenderPlan: DcpRenderPlan? = null,
|
||||
spectralFilmLut: SpectralFilmLut? = null,
|
||||
agxLut: AgxLut? = null,
|
||||
arriLut: ArriLut? = null,
|
||||
colorEngine: RawColorEngine = RawColorEngine.AdobeCurve,
|
||||
workingColorSpace: ColorSpace = ColorSpace.ProPhoto,
|
||||
shadowsHighlightsParams: ShadowsHighlightsParams = ShadowsHighlightsParams.NEUTRAL,
|
||||
viewportWidth: Int = metadata.width,
|
||||
viewportHeight: Int = metadata.height
|
||||
) {
|
||||
val baseCurve = dcpRenderPlan?.toneCurveLut ?: ACR3Curve.samples()
|
||||
val outputTransform = computeWorkingToOutputTransform(ColorSpace.ProPhoto, ColorSpace.SRGB)
|
||||
val outputTransform = computeWorkingToOutputTransform(workingColorSpace, ColorSpace.SRGB)
|
||||
|
||||
GLES30.glUseProgram(combinedProgram)
|
||||
checkGlError("renderCombinedPass glUseProgram")
|
||||
@@ -3793,6 +3899,9 @@ class RawDemosaicProcessor {
|
||||
bindAgxCombinedResource(
|
||||
agxLut = if (colorEngine == RawColorEngine.AgX) agxLut else null
|
||||
)
|
||||
bindArriCombinedResource(
|
||||
arriLut = if (colorEngine == RawColorEngine.ARRI) arriLut else null
|
||||
)
|
||||
GLES30.glUniform1i(
|
||||
GLES30.glGetUniformLocation(combinedProgram, "uRawColorEngine"),
|
||||
colorEngine.shaderId
|
||||
@@ -4931,6 +5040,11 @@ class RawDemosaicProcessor {
|
||||
agxLutTextureId = 0
|
||||
agxLutTextureKey = null
|
||||
}
|
||||
if (arriLutTextureId != 0) {
|
||||
GLES30.glDeleteTextures(1, intArrayOf(arriLutTextureId), 0)
|
||||
arriLutTextureId = 0
|
||||
arriLutTextureKey = null
|
||||
}
|
||||
if (dummyDcp3DTextureId != 0) GLES30.glDeleteTextures(1, intArrayOf(dummyDcp3DTextureId), 0)
|
||||
if (dummyDcpToneCurveTextureId != 0) GLES30.glDeleteTextures(
|
||||
1,
|
||||
|
||||
@@ -96,6 +96,7 @@ object RawShaders {
|
||||
uniform sampler3D uDcpLookTableTexture;
|
||||
uniform sampler3D uSpectralFilmTexture;
|
||||
uniform sampler3D uAgxBaseSrgbTexture;
|
||||
uniform sampler3D uArriLogC4LutTexture;
|
||||
uniform mat3 uOutputTransform;
|
||||
uniform float uCurveSize;
|
||||
uniform bool uCurveEnabled;
|
||||
@@ -110,11 +111,15 @@ object RawShaders {
|
||||
uniform int uDcpLookTableEncoding;
|
||||
uniform int uSpectralFilmSize;
|
||||
uniform int uAgxLutSize;
|
||||
uniform int uArriLutSize;
|
||||
uniform int uRawColorEngine;
|
||||
uniform vec4 uLogC4Params0;
|
||||
uniform vec4 uLogC4Params1;
|
||||
|
||||
const int RAW_COLOR_ENGINE_ADOBE_CURVE = 0;
|
||||
const int RAW_COLOR_ENGINE_AGX = 1;
|
||||
const int RAW_COLOR_ENGINE_SPECTRAL_FILM = 2;
|
||||
const int RAW_COLOR_ENGINE_ARRI = 3;
|
||||
const float AGX_LOG_MIN = -12.47393;
|
||||
const float AGX_LOG_MAX = 12.5260688117;
|
||||
|
||||
@@ -377,30 +382,30 @@ object RawShaders {
|
||||
return proPhotoToLinear(lutResult);
|
||||
}
|
||||
|
||||
vec3 fetchAgxBaseSrgb(ivec3 coord) {
|
||||
ivec3 maxCoord = ivec3(max(uAgxLutSize - 1, 0));
|
||||
return texelFetch(uAgxBaseSrgbTexture, clamp(coord, ivec3(0), maxCoord), 0).rgb;
|
||||
vec3 fetchCubeLut(sampler3D lutTexture, int lutSize, ivec3 coord) {
|
||||
ivec3 maxCoord = ivec3(max(lutSize - 1, 0));
|
||||
return texelFetch(lutTexture, clamp(coord, ivec3(0), maxCoord), 0).rgb;
|
||||
}
|
||||
|
||||
vec3 sampleAgxBaseSrgb(vec3 coord) {
|
||||
if (uAgxLutSize <= 1) {
|
||||
vec3 sampleCubeLut(sampler3D lutTexture, int lutSize, vec3 coord) {
|
||||
if (lutSize <= 1) {
|
||||
return coord;
|
||||
}
|
||||
|
||||
float maxIndex = float(uAgxLutSize - 1);
|
||||
float maxIndex = float(lutSize - 1);
|
||||
vec3 scaled = clamp(coord, vec3(0.0), vec3(1.0)) * maxIndex;
|
||||
ivec3 p0 = ivec3(floor(scaled));
|
||||
ivec3 p1 = min(p0 + ivec3(1), ivec3(uAgxLutSize - 1));
|
||||
ivec3 p1 = min(p0 + ivec3(1), ivec3(lutSize - 1));
|
||||
vec3 f = scaled - vec3(p0);
|
||||
|
||||
vec3 c000 = fetchAgxBaseSrgb(p0);
|
||||
vec3 c100 = fetchAgxBaseSrgb(ivec3(p1.x, p0.y, p0.z));
|
||||
vec3 c010 = fetchAgxBaseSrgb(ivec3(p0.x, p1.y, p0.z));
|
||||
vec3 c001 = fetchAgxBaseSrgb(ivec3(p0.x, p0.y, p1.z));
|
||||
vec3 c110 = fetchAgxBaseSrgb(ivec3(p1.x, p1.y, p0.z));
|
||||
vec3 c101 = fetchAgxBaseSrgb(ivec3(p1.x, p0.y, p1.z));
|
||||
vec3 c011 = fetchAgxBaseSrgb(ivec3(p0.x, p1.y, p1.z));
|
||||
vec3 c111 = fetchAgxBaseSrgb(p1);
|
||||
vec3 c000 = fetchCubeLut(lutTexture, lutSize, p0);
|
||||
vec3 c100 = fetchCubeLut(lutTexture, lutSize, ivec3(p1.x, p0.y, p0.z));
|
||||
vec3 c010 = fetchCubeLut(lutTexture, lutSize, ivec3(p0.x, p1.y, p0.z));
|
||||
vec3 c001 = fetchCubeLut(lutTexture, lutSize, ivec3(p0.x, p0.y, p1.z));
|
||||
vec3 c110 = fetchCubeLut(lutTexture, lutSize, ivec3(p1.x, p1.y, p0.z));
|
||||
vec3 c101 = fetchCubeLut(lutTexture, lutSize, ivec3(p1.x, p0.y, p1.z));
|
||||
vec3 c011 = fetchCubeLut(lutTexture, lutSize, ivec3(p0.x, p1.y, p1.z));
|
||||
vec3 c111 = fetchCubeLut(lutTexture, lutSize, p1);
|
||||
|
||||
if (f.x >= f.y) {
|
||||
if (f.y >= f.z) {
|
||||
@@ -421,6 +426,14 @@ object RawShaders {
|
||||
}
|
||||
}
|
||||
|
||||
vec3 sampleAgxBaseSrgb(vec3 coord) {
|
||||
return sampleCubeLut(uAgxBaseSrgbTexture, uAgxLutSize, coord);
|
||||
}
|
||||
|
||||
vec3 sampleArriLogC4ToGamma24Rec709(vec3 coord) {
|
||||
return sampleCubeLut(uArriLogC4LutTexture, uArriLutSize, coord);
|
||||
}
|
||||
|
||||
vec3 agxLogEncode(vec3 color) {
|
||||
vec3 safeColor = max(color, vec3(exp2(AGX_LOG_MIN)));
|
||||
return clamp(
|
||||
@@ -440,6 +453,45 @@ object RawShaders {
|
||||
return pow(max(rec1886Encoded, vec3(0.0)), vec3(2.4));
|
||||
}
|
||||
|
||||
float log10Safe(float value) {
|
||||
return log(max(value, 1e-20)) / log(10.0);
|
||||
}
|
||||
|
||||
float linearToLogC4(float reflection) {
|
||||
float a = uLogC4Params0.x;
|
||||
float b = uLogC4Params0.y;
|
||||
float c = uLogC4Params0.z;
|
||||
float d = uLogC4Params0.w;
|
||||
float e = uLogC4Params1.x;
|
||||
float f = uLogC4Params1.y;
|
||||
float cut1 = uLogC4Params1.z;
|
||||
if (reflection >= cut1) {
|
||||
return c * log10Safe(a * reflection + b) + d;
|
||||
}
|
||||
return e * reflection + f;
|
||||
}
|
||||
|
||||
vec3 linearToLogC4(vec3 color) {
|
||||
return clamp(
|
||||
vec3(
|
||||
linearToLogC4(color.r),
|
||||
linearToLogC4(color.g),
|
||||
linearToLogC4(color.b)
|
||||
),
|
||||
vec3(0.0),
|
||||
vec3(1.0)
|
||||
);
|
||||
}
|
||||
|
||||
vec3 applyArri(vec3 color) {
|
||||
if (uArriLutSize <= 1) {
|
||||
return uOutputTransform * applyAdobeCurve(color);
|
||||
}
|
||||
vec3 logC4 = linearToLogC4(max(color, vec3(0.0)));
|
||||
vec3 gamma24Rec709 = sampleArriLogC4ToGamma24Rec709(logC4);
|
||||
return pow(max(gamma24Rec709, vec3(0.0)), vec3(2.4));
|
||||
}
|
||||
|
||||
float proPhotoLuminance(vec3 color) {
|
||||
return max(dot(color, vec3(0.2880402, 0.7118741, 0.0000857)), 1e-5);
|
||||
}
|
||||
@@ -473,6 +525,9 @@ object RawShaders {
|
||||
if (uRawColorEngine == RAW_COLOR_ENGINE_AGX) {
|
||||
return applyAgX(color);
|
||||
}
|
||||
if (uRawColorEngine == RAW_COLOR_ENGINE_ARRI) {
|
||||
return applyArri(color);
|
||||
}
|
||||
if (uRawColorEngine == RAW_COLOR_ENGINE_SPECTRAL_FILM && uSpectralFilmSize > 1) {
|
||||
return applySpectralFilm(color);
|
||||
}
|
||||
@@ -482,7 +537,7 @@ object RawShaders {
|
||||
}
|
||||
|
||||
vec3 applyOutputTransformAfterDisplayTone(vec3 color) {
|
||||
if (uRawColorEngine == RAW_COLOR_ENGINE_AGX) {
|
||||
if (uRawColorEngine == RAW_COLOR_ENGINE_AGX || uRawColorEngine == RAW_COLOR_ENGINE_ARRI) {
|
||||
return color;
|
||||
}
|
||||
return uOutputTransform * color;
|
||||
|
||||
@@ -492,6 +492,7 @@ private fun rawColorEngineName(engine: RawColorEngine): String {
|
||||
RawColorEngine.AdobeCurve -> stringResource(R.string.settings_raw_color_engine_adobe_curve)
|
||||
RawColorEngine.AgX -> stringResource(R.string.settings_raw_color_engine_agx)
|
||||
RawColorEngine.SpectralFilm -> stringResource(R.string.settings_raw_color_engine_spectral_film)
|
||||
RawColorEngine.ARRI -> stringResource(R.string.settings_raw_color_engine_arri)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,6 +502,7 @@ private fun rawColorEngineDescription(engine: RawColorEngine): String {
|
||||
RawColorEngine.AdobeCurve -> stringResource(R.string.settings_raw_color_engine_adobe_curve_description)
|
||||
RawColorEngine.AgX -> stringResource(R.string.settings_raw_color_engine_agx_description)
|
||||
RawColorEngine.SpectralFilm -> stringResource(R.string.settings_raw_color_engine_spectral_film_description)
|
||||
RawColorEngine.ARRI -> stringResource(R.string.settings_raw_color_engine_arri_description)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -389,6 +389,7 @@ fun PresetEditorScreen(
|
||||
RawColorEngine.AdobeCurve -> stringResource(R.string.settings_raw_color_engine_adobe_curve)
|
||||
RawColorEngine.AgX -> stringResource(R.string.settings_raw_color_engine_agx)
|
||||
RawColorEngine.SpectralFilm -> stringResource(R.string.settings_raw_color_engine_spectral_film)
|
||||
RawColorEngine.ARRI -> stringResource(R.string.settings_raw_color_engine_arri)
|
||||
}
|
||||
}
|
||||
DropdownSettingItem(
|
||||
|
||||
@@ -655,6 +655,8 @@
|
||||
<string name="settings_raw_color_engine_agx_description">使用 Blender AgX 成像,并采用更宽的 RAW 工作空间。</string>
|
||||
<string name="settings_raw_color_engine_spectral_film">光谱胶片</string>
|
||||
<string name="settings_raw_color_engine_spectral_film_description">模拟胶卷和相纸介质,并支持密度微调。</string>
|
||||
<string name="settings_raw_color_engine_arri">ARRI LogC4</string>
|
||||
<string name="settings_raw_color_engine_arri_description">使用 ARRI Wide Gamut 4,并通过 LogC4 到 Rec.709 Gamma 2.4 的 LUT 成像。</string>
|
||||
<string name="settings_spectral_film">光谱胶片模拟</string>
|
||||
<string name="settings_spectral_film_description">模拟经典底片和打印介质的色彩响应与物理特征曲线。</string>
|
||||
<string name="settings_negative_film">底片胶卷</string>
|
||||
|
||||
@@ -639,6 +639,8 @@
|
||||
<string name="settings_raw_color_engine_agx_description">Blender AgX tone formation with a wider RAW working space.</string>
|
||||
<string name="settings_raw_color_engine_spectral_film">Spectral Film</string>
|
||||
<string name="settings_raw_color_engine_spectral_film_description">Film stock and print medium simulation with density tuning.</string>
|
||||
<string name="settings_raw_color_engine_arri">ARRI LogC4</string>
|
||||
<string name="settings_raw_color_engine_arri_description">ARRI Wide Gamut 4 with LogC4 to Rec.709 Gamma 2.4 rendering.</string>
|
||||
<string name="settings_spectral_film">Spectral Film Simulation</string>
|
||||
<string name="settings_spectral_film_description">Simulate classic negative film and print medium color curves.</string>
|
||||
<string name="settings_negative_film">Negative Film</string>
|
||||
|
||||
Reference in new issue
Block a user