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
17 lines
590 B
Plaintext
17 lines
590 B
Plaintext
/* A basic perspective camera. */
|
|
|
|
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)
|
|
{
|
|
vector sensor_size;
|
|
getattribute("cam:sensor_size", sensor_size);
|
|
|
|
point Pcam = camera_shader_raster_position() - point(0.5);
|
|
Pcam *= sensor_size / focal_length;
|
|
direction = normalize(vector(Pcam.x, Pcam.y, 1.0));
|
|
}
|