mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
fix translucency model using new permittance setting
This commit is contained in:
parent
88b424d36a
commit
b88183f4a1
3 changed files with 33 additions and 4 deletions
|
@ -165,6 +165,29 @@ UM.Dialog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UM.TooltipArea {
|
||||||
|
Layout.fillWidth:true
|
||||||
|
height: childrenRect.height
|
||||||
|
text: catalog.i18nc("@info:tooltip","The percentage of light penetrating a print with a thickness of 1 millimeter.")
|
||||||
|
Row {
|
||||||
|
width: parent.width
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: catalog.i18nc("@action:label", "1mm Transmittance (%)")
|
||||||
|
width: 150 * screenScaleFactor
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
TextField {
|
||||||
|
id: transmittance
|
||||||
|
objectName: "Transmittance"
|
||||||
|
focus: true
|
||||||
|
validator: RegExpValidator {regExp: /^[1-9]\d{0,2}([\,|\.]\d*)?$/}
|
||||||
|
width: 180 * screenScaleFactor
|
||||||
|
onTextChanged: { manager.onTransmittanceChanged(text) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UM.TooltipArea {
|
UM.TooltipArea {
|
||||||
Layout.fillWidth:true
|
Layout.fillWidth:true
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
|
|
|
@ -48,9 +48,9 @@ class ImageReader(MeshReader):
|
||||||
|
|
||||||
def _read(self, file_name):
|
def _read(self, file_name):
|
||||||
size = max(self._ui.getWidth(), self._ui.getDepth())
|
size = max(self._ui.getWidth(), self._ui.getDepth())
|
||||||
return self._generateSceneNode(file_name, size, self._ui.peak_height, self._ui.base_height, self._ui.smoothing, 512, self._ui.lighter_is_higher, self._ui.use_logarithmic_function)
|
return self._generateSceneNode(file_name, size, self._ui.peak_height, self._ui.base_height, self._ui.smoothing, 512, self._ui.lighter_is_higher, self._ui.use_logarithmic_function, self._ui.transmittance_1mm)
|
||||||
|
|
||||||
def _generateSceneNode(self, file_name, xz_size, peak_height, base_height, blur_iterations, max_size, lighter_is_higher, use_logarithmic_function):
|
def _generateSceneNode(self, file_name, xz_size, peak_height, base_height, blur_iterations, max_size, lighter_is_higher, use_logarithmic_function, transmittance_1mm):
|
||||||
scene_node = SceneNode()
|
scene_node = SceneNode()
|
||||||
|
|
||||||
mesh = MeshBuilder()
|
mesh = MeshBuilder()
|
||||||
|
@ -127,10 +127,11 @@ class ImageReader(MeshReader):
|
||||||
Job.yieldThread()
|
Job.yieldThread()
|
||||||
|
|
||||||
if use_logarithmic_function:
|
if use_logarithmic_function:
|
||||||
min_luminance = 2.0 ** (peak_height - base_height)
|
p = 1.0 / math.log(transmittance_1mm / 100.0, 2)
|
||||||
|
min_luminance = 2.0 ** ((peak_height - base_height) / p)
|
||||||
for (y, x) in numpy.ndindex(height_data.shape):
|
for (y, x) in numpy.ndindex(height_data.shape):
|
||||||
mapped_luminance = min_luminance + (1.0 - min_luminance) * height_data[y, x]
|
mapped_luminance = min_luminance + (1.0 - min_luminance) * height_data[y, x]
|
||||||
height_data[y, x] = peak_height - math.log(mapped_luminance, 2)
|
height_data[y, x] = peak_height - p * math.log(mapped_luminance, 2)
|
||||||
else:
|
else:
|
||||||
height_data *= scale_vector.y
|
height_data *= scale_vector.y
|
||||||
height_data += base_height
|
height_data += base_height
|
||||||
|
|
|
@ -35,6 +35,7 @@ class ImageReaderUI(QObject):
|
||||||
self.smoothing = 1
|
self.smoothing = 1
|
||||||
self.lighter_is_higher = False;
|
self.lighter_is_higher = False;
|
||||||
self.use_logarithmic_function = False;
|
self.use_logarithmic_function = False;
|
||||||
|
self.transmittance_1mm = 40.0;
|
||||||
|
|
||||||
self._ui_lock = threading.Lock()
|
self._ui_lock = threading.Lock()
|
||||||
self._cancelled = False
|
self._cancelled = False
|
||||||
|
@ -76,6 +77,7 @@ class ImageReaderUI(QObject):
|
||||||
|
|
||||||
self._ui_view.findChild(QObject, "Base_Height").setProperty("text", str(self.base_height))
|
self._ui_view.findChild(QObject, "Base_Height").setProperty("text", str(self.base_height))
|
||||||
self._ui_view.findChild(QObject, "Peak_Height").setProperty("text", str(self.peak_height))
|
self._ui_view.findChild(QObject, "Peak_Height").setProperty("text", str(self.peak_height))
|
||||||
|
self._ui_view.findChild(QObject, "Transmittance").setProperty("text", str(self.transmittance_1mm))
|
||||||
self._ui_view.findChild(QObject, "Smoothing").setProperty("value", self.smoothing)
|
self._ui_view.findChild(QObject, "Smoothing").setProperty("value", self.smoothing)
|
||||||
|
|
||||||
def _createConfigUI(self):
|
def _createConfigUI(self):
|
||||||
|
@ -150,3 +152,6 @@ class ImageReaderUI(QObject):
|
||||||
def onConvertFunctionChanged(self, value):
|
def onConvertFunctionChanged(self, value):
|
||||||
self.use_logarithmic_function = (value == 0)
|
self.use_logarithmic_function = (value == 0)
|
||||||
|
|
||||||
|
@pyqtSlot(int)
|
||||||
|
def onTransmittanceChanged(self, value):
|
||||||
|
self.transmittance_1mm = value
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue