amaranth icon indicating copy to clipboard operation
amaranth copied to clipboard

Added saved curve settings in Color Management

Open schroef opened this issue 3 years ago • 0 comments

Always nice to use this addon. I hardly know what is Blender Vanilla and what is from this addon. Remember when i started using 2.80 that i was missing it so i started porting it, someone beat me to it. Though i still prefer the older method of the missing links. Think im going to revert that again. Anyways...

I was noticing that curves didnt do anything when settings are saved. I remembered an addon where i also implemented a curve so i knew the data of those points can be reached. Then started to thinker with the AddPresetBase function/operator.

I know got it working, it saves every curve which has been edited, 4 that is C,R,G,B it now also saves all the other settings which were missing.

ill make a fork and do a pull request. I tried to keep the code as clean as i could. Im no pro dev, so perhaps lots of my code can be simplified, but it works thats good for me https://user-images.githubusercontent.com/6923008/113667093-4bff4b80-967e-11eb-9fe3-e49b94b73b7d.mp4

This is what a file looked prior

import bpy
scene = bpy.context.scene

scene.view_settings.view_transform = 'Filmic'
scene.display_settings.display_device = 'sRGB'
scene.view_settings.exposure = 0.0
scene.view_settings.gamma = 1.0
scene.view_settings.look = 'Low Contrast'
scene.view_settings.use_curve_mapping = True
scene.sequencer_colorspace_settings.name = 'sRGB'

This is how it looks now with saved curves settings. I could perhaps better use a DICT but im not really at home with those. Ill try to do some more research, could save a lot of lines

import bpy
scene = bpy.context.scene

view = scene.view_settings
cm = view.curve_mapping

# Dirty delete < 2.92 doesnt have operator
if bpy.app.version <= (2,93):
    for l in range(len(cm.curves)):
        totCpts = len(cm.curves[l].points)
        #First delete all export first and list
        if totCpts > 2:
            for i in range(1,totCpts-1):
                cm.initialize()
                cm.update()
                newIdx = len(cm.curves[l].points)
                cm.curves[l].points.remove(cm.curves[l].points[(newIdx-2)])
            #Reset first and last to 0,0 and 1,1
            resetLst = [(0.0,0.0),(1.0,1.0)]
            for i in range(2):
                cm.initialize()
                cm.update()
                cm.curves[l].points[i].location=resetLst[i]
        cm.update()

rPtsList=[(0.0, 0.0), (1.0, 1.0)]
for i in range(2):
   # Update first and last > dont add new
   if i == 0 or i == (len(rPtsList)-1):
       cm.curves[0].points[i].location=rPtsList[i]
   else:
       cm.curves[0].points.new(float(rPtsList[i][0]),float(rPtsList[i][1]))

gPtsList=[(0.0, 0.0), (1.0, 1.0)]
for i in range(2):
   # Update first and last > dont add new
   if i == 0 or i == (len(gPtsList)-1):
       cm.curves[1].points[i].location=gPtsList[i]
   else:
       cm.curves[1].points.new(float(gPtsList[i][0]),float(gPtsList[i][1]))

bPtsList=[(0.0, 0.0), (1.0, 1.0)]
for i in range(2):
   # Update first and last > dont add new
   if i == 0 or i == (len(bPtsList)-1):
       cm.curves[2].points[i].location=bPtsList[i]
   else:
       cm.curves[2].points.new(float(bPtsList[i][0]),float(bPtsList[i][1]))

cPtsList=[(0.17073175311088562, 0.49999988079071045), (0.4668988585472107, 0.2312503159046173), (0.7665510177612305, 0.6562495827674866)]
for i in range(3):
   # Update first and last > dont add new
   if i == 0 or i == (len(cPtsList)-1):
       cm.curves[3].points[i].location=cPtsList[i]
   else:
       cm.curves[3].points.new(float(cPtsList[i][0]),float(cPtsList[i][1]))


cm.black_level.hsv=(0.0, 0.0, 0.0)
cm.white_level.hsv=(0.0, 0.0, 1.0)
cm.clip_max_x=1.0
cm.clip_max_y=1.0
cm.clip_min_x=0.0
cm.clip_min_y=0.0
cm.update()

scene.view_settings.view_transform = 'Filmic'
scene.display_settings.display_device = 'sRGB'
scene.view_settings.exposure = 0.0
scene.view_settings.gamma = 1.0
scene.view_settings.look = 'None'
scene.view_settings.use_curve_mapping = True
scene.sequencer_colorspace_settings.name = 'sRGB'

schroef avatar Apr 06 '21 06:04 schroef