Cycles: OSL Camera: Allow mm as parameter unit, use as cam distance
Commit 6c6d1a9b63 allowed several units to OSL camera shaders'
parameters. Only meters 'm' were supported as distance units, because
others cannot be converted automatically into the shader' unit.
This commit allows using 'mm' in addition to 'm', and makes the
Blender property use a 'DISTANCE_CAMERA' subtype. This assumes that
someone using 'mm' specifically wants to use the value for camera
parameters, which means it can be used as is, without any conversion
in the shader.
The camera templates were updated to use a focal length in mm.
Pull Request: https://projects.blender.org/blender/blender/pulls/147347
This commit is contained in:
committed by
Lukas Stockner
parent
3ad589e973
commit
9d0266280f
@@ -150,6 +150,8 @@ def osl_param_ensure_property(ccam, param):
|
|||||||
ui.update(subtype='ANGLE')
|
ui.update(subtype='ANGLE')
|
||||||
elif datatype is float and metadata.get('unit') == 'm':
|
elif datatype is float and metadata.get('unit') == 'm':
|
||||||
ui.update(subtype='DISTANCE')
|
ui.update(subtype='DISTANCE')
|
||||||
|
elif datatype is float and metadata.get('unit') == 'mm':
|
||||||
|
ui.update(subtype='DISTANCE_CAMERA')
|
||||||
elif datatype is float and metadata.get('unit') in ('s', 'sec'):
|
elif datatype is float and metadata.get('unit') in ('s', 'sec'):
|
||||||
ui.update(subtype='TIME_ABSOLUTE')
|
ui.update(subtype='TIME_ABSOLUTE')
|
||||||
elif metadata.get('slider'):
|
elif metadata.get('slider'):
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ float invertDistortionModel(float x, float y, float k1, float k2, float k3)
|
|||||||
return -1.0;
|
return -1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
shader camera(float focal_length = 50.0 [[ float min = 0.0, float sensitivity = 0.2 ]],
|
shader camera(float focal_length = 50.0 [[ float min = 0.0,
|
||||||
|
string unit = "mm",
|
||||||
|
float sensitivity = 0.2 ]],
|
||||||
int do_distortion = 0 [[ string widget = "checkBox"]],
|
int do_distortion = 0 [[ string widget = "checkBox"]],
|
||||||
int do_swirl = 0 [[ string widget = "checkBox"]],
|
int do_swirl = 0 [[ string widget = "checkBox"]],
|
||||||
int do_dof = 0 [[ string widget = "checkBox"]],
|
int do_dof = 0 [[ string widget = "checkBox"]],
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
/* A basic perspective camera. */
|
/* A basic perspective camera. */
|
||||||
|
|
||||||
shader camera(float focal_length = 90.0,
|
shader camera(float focal_length = 90.0 [[ float min = 0.0,
|
||||||
|
string unit = "mm",
|
||||||
|
float sensitivity = 0.2 ]],
|
||||||
output point position = 0.0,
|
output point position = 0.0,
|
||||||
output vector direction = 0.0,
|
output vector direction = 0.0,
|
||||||
output color throughput = 1.0)
|
output color throughput = 1.0)
|
||||||
|
|||||||
Reference in New Issue
Block a user