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:
Damien Picard
2025-10-13 02:52:16 +02:00
committed by Lukas Stockner
parent 3ad589e973
commit 9d0266280f
3 changed files with 8 additions and 2 deletions

View File

@@ -26,7 +26,9 @@ float invertDistortionModel(float x, float y, float k1, float k2, float k3)
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_swirl = 0 [[ string widget = "checkBox"]],
int do_dof = 0 [[ string widget = "checkBox"]],

View File

@@ -1,6 +1,8 @@
/* 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 vector direction = 0.0,
output color throughput = 1.0)