From fbc03fdd10836f79c509e5d8c19514bc5f983253 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 10 Mar 2018 20:25:27 +0100 Subject: Cycles: update addons for squared roughness convention. --- materials_utils/material_converter.py | 3 ++- materials_utils/materials_cycles_converter.py | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'materials_utils') diff --git a/materials_utils/material_converter.py b/materials_utils/material_converter.py index c682e612..bf52bec1 100644 --- a/materials_utils/material_converter.py +++ b/materials_utils/material_converter.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import bpy +import math from mathutils import Vector from bpy.types import Operator from .warning_messages_utils import ( @@ -665,7 +666,7 @@ def makeCyclesFromBI(cmat): # Make Diffuse and Output nodes mainShader = makeMainShader(TreeNodes) - mainShader.inputs['Roughness'].default_value = cmat.specular_intensity + mainShader.inputs['Roughness'].default_value = math.sqrt(max(cmat.specular_intensity, 0.0)) mainDiffuse = mainShader materialOutput = makeMaterialOutput(TreeNodes) links.new(mainShader.outputs['BSDF'], materialOutput.inputs['Surface']) diff --git a/materials_utils/materials_cycles_converter.py b/materials_utils/materials_cycles_converter.py index ddd4eb6e..13e1e1ec 100644 --- a/materials_utils/materials_cycles_converter.py +++ b/materials_utils/materials_cycles_converter.py @@ -6,7 +6,7 @@ import bpy from os import path as os_path from bpy.types import Operator from math import ( - log2, ceil, + log2, ceil, sqrt, ) from bpy.props import ( BoolProperty, @@ -381,7 +381,7 @@ def AutoNode(active=False, operator=None): else: # Create Clay Material (Diffuse, Glossy, Layer Weight) shader.inputs['Color'].default_value = PAINT_SC_COLOR - shader.inputs['Roughness'].default_value = 0.9 + shader.inputs['Roughness'].default_value = 0.9486 # remove Color Ramp and links from the default shader and reroute try: @@ -415,10 +415,10 @@ def AutoNode(active=False, operator=None): shader.inputs['Roughness'].default_value = cmat.specular_intensity if shader.type == 'ShaderNodeBsdfGlossy': - shader.inputs['Roughness'].default_value = 1 - cmat.raytrace_mirror.gloss_factor + shader.inputs['Roughness'].default_value = sqrt(max(1 - cmat.raytrace_mirror.gloss_factor, 0.0)) if shader.type == 'ShaderNodeBsdfGlass': - shader.inputs['Roughness'].default_value = 1 - cmat.raytrace_mirror.gloss_factor + shader.inputs['Roughness'].default_value = sqrt(max(1 - cmat.raytrace_mirror.gloss_factor, 0.0)) shader.inputs['IOR'].default_value = cmat.raytrace_transparency.ior if shader.type == 'ShaderNodeEmission': -- cgit v1.2.3