<commit_before>from . import string_utils
from . import property_utils
from . import shadergraph_utils
from .. import rman_constants
from .. import rman_config
from collections import OrderedDict
from copy import deepcopy
import bpy
import os
import getpass

__BLENDER_TO_RMAN_DSPY__ = { 'TIFF': 'tiff', 'TARGA': 'targa', 'TARGA_RAW': 'targa', 'OPEN_EXR': 'openexr', 'PNG': 'png'}

def get_channel_name(aov, layer_name):
    aov_name = aov.name.replace(' ', '')
    aov_channel_name = aov.channel_name
    if not aov.aov_name or not aov.channel_name:
        return ''
    elif aov.aov_name == "color rgba":
        aov_channel_name = "Ci,a"
    # Remaps any color lpe channel names to a denoise friendly one
    elif aov_name in channel_name_map.keys():
        aov_channel_name = '%s_%s_%s' % (
            channel_name_map[aov_name], aov_name, layer_name)

    elif aov.aov_name == "color custom_lpe":
        aov_channel_name = aov.name

    else:
        aov_channel_name = '%s_%s' % (
            aov_name, layer_name)

    return aov_channel_name

def _default_dspy_params():
    d = {}
    d[u'enable'] = { 'type': u'int', 'value': True}
    d[u'lpeLightGroup'] = { 'type': u'string', 'value': None}
    d[u'remap_a'] = { 'type': u'float', 'value': 0.0}
    d[u'remap_b'] = { 'type': u'float', 'value': 0.0}
    d[u'remap_c'] = { 'type': u'float', 'value': 0.0}  
    d[u'exposure'] = { 'type': u'float2', 'value': [1.0, 1.0] }
    d[u'filter'] = {'type': u'string', 'value': 'default'}
    d[u'filterwidth'] = { 'type': u'float2', 'value': [2,2]}   
    d[u'statistics'] = { 'type': u'string', 'value': 'none'}

    return d    

def _add_stylized_channels(dspys_dict, dspy_drv, rman_scene, expandTokens):
    """
    Add the necessary dspy channels for stylized looks. 
    """ 
    stylized_tmplt = rman_config.__RMAN_DISPLAY_TEMPLATES__.get('Stylized', None)
    if not stylized_tmplt:
        return  

    rm = rman_scene.bl_scene.renderman
    display_driver = dspy_drv
    rman_dspy_channels = rman_config.__RMAN_DISPLAY_CHANNELS__

    if not display_driver:
        display_driver = __BLENDER_TO_RMAN_DSPY__.get(rman_scene.bl_scene.render.image_settings.file_format, 'openexr')
        if 'display' in stylized_tmplt:
            display_driver = stylized_tmplt['display']['displayType']        

    if display_driver == 'blender' and rman_scene.is_viewport_render:
        display_driver = 'null'

        for chan in stylized_tmplt['channels']:
            dspy_params = {}                        
            dspy_params['displayChannels'] = []
            dspy_name = '%s_%s' % (stylized_tmplt.get('displayName', 'rman_stylized'), chan)

            d = _default_dspy_params()
            if chan not in dspys_dict['channels']:
                d = _default_dspy_params()
                settings = rman_dspy_channels[chan]
                chan_src = settings['channelSource']
                chan_type = settings['channelType']
                d[u'channelSource'] = {'type': u'string', 'value': chan_src}
                d[u'channelType'] = { 'type': u'string', 'value': chan_type}                  
                dspys_dict['channels'][chan] = d
            dspy_params['displayChannels'].append(chan)

            filePath = '%s_%s' % (dspy_name, chan)         
<commit_msg>If rendering to it or the Blender display driver, split up the stylized channels.<commit_after>from . import string_utils
from . import property_utils
from . import shadergraph_utils
from .. import rman_constants
from .. import rman_config
from collections import OrderedDict
from copy import deepcopy
import bpy
import os
import getpass

__BLENDER_TO_RMAN_DSPY__ = { 'TIFF': 'tiff', 'TARGA': 'targa', 'TARGA_RAW': 'targa', 'OPEN_EXR': 'openexr', 'PNG': 'png'}

def get_channel_name(aov, layer_name):
    aov_name = aov.name.replace(' ', '')
    aov_channel_name = aov.channel_name
    if not aov.aov_name or not aov.channel_name:
        return ''
    elif aov.aov_name == "color rgba":
        aov_channel_name = "Ci,a"
    # Remaps any color lpe channel names to a denoise friendly one
    elif aov_name in channel_name_map.keys():
        aov_channel_name = '%s_%s_%s' % (
            channel_name_map[aov_name], aov_name, layer_name)

    elif aov.aov_name == "color custom_lpe":
        aov_channel_name = aov.name

    else:
        aov_channel_name = '%s_%s' % (
            aov_name, layer_name)

    return aov_channel_name

def _default_dspy_params():
    d = {}
    d[u'enable'] = { 'type': u'int', 'value': True}
    d[u'lpeLightGroup'] = { 'type': u'string', 'value': None}
    d[u'remap_a'] = { 'type': u'float', 'value': 0.0}
    d[u'remap_b'] = { 'type': u'float', 'value': 0.0}
    d[u'remap_c'] = { 'type': u'float', 'value': 0.0}  
    d[u'exposure'] = { 'type': u'float2', 'value': [1.0, 1.0] }
    d[u'filter'] = {'type': u'string', 'value': 'default'}
    d[u'filterwidth'] = { 'type': u'float2', 'value': [2,2]}   
    d[u'statistics'] = { 'type': u'string', 'value': 'none'}

    return d    

def _add_stylized_channels(dspys_dict, dspy_drv, rman_scene, expandTokens):
    """
    Add the necessary dspy channels for stylized looks. 
    """ 
    stylized_tmplt = rman_config.__RMAN_DISPLAY_TEMPLATES__.get('Stylized', None)
    if not stylized_tmplt:
        return  

    rm = rman_scene.bl_scene.renderman
    display_driver = dspy_drv
    rman_dspy_channels = rman_config.__RMAN_DISPLAY_CHANNELS__

    if not display_driver:
        display_driver = __BLENDER_TO_RMAN_DSPY__.get(rman_scene.bl_scene.render.image_settings.file_format, 'openexr')
        if 'display' in stylized_tmplt:
            display_driver = stylized_tmplt['display']['displayType']        

    if display_driver in ['it', 'blender']:
        if rman_scene.is_viewport_render:
            display_driver = 'null'

        for chan in stylized_tmplt['channels']:
            dspy_params = {}                        
            dspy_params['displayChannels'] = []
            dspy_name = '%s_%s' % (stylized_tmplt.get('displayName', 'rman_stylized'), chan)

            d = _default_dspy_params()
            if chan not in dspys_dict['channels']:
                d = _default_dspy_params()
                settings = rman_dspy_channels[chan]
                chan_src = settings['channelSource']
                chan_type = settings['channelType']
                d[u'channelSource'] = {'type': u'string', 'value': chan_src}
                d[u'channelType'] = { 'type': u'string', 'value': chan_type}                  
                dspys_dict['channels'][chan] = d
            dspy_params['displayChannels'].append(chan)

            filePath = '%s_%s' % (dspy_name, chan)         

{'fraction_non_alphanumeric': 0.13423019431988042, 'fraction_numerical': 0.004185351270553065, 'mean_word_length': 2.8498273878020712, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6688497', 'n_tokens_mistral': 2448, 'n_tokens_neox': 2360, 'n_words': 479}