OLD | NEW |
1 /* | 1 /* |
2 Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al. | 2 Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al. |
3 All Rights Reserved. | 3 All Rights Reserved. |
4 | 4 |
5 Redistribution and use in source and binary forms, with or without | 5 Redistribution and use in source and binary forms, with or without |
6 modification, are permitted provided that the following conditions are | 6 modification, are permitted provided that the following conditions are |
7 met: | 7 met: |
8 * Redistributions of source code must retain the above copyright | 8 * Redistributions of source code must retain the above copyright |
9 notice, this list of conditions and the following disclaimer. | 9 notice, this list of conditions and the following disclaimer. |
10 * Redistributions in binary form must reproduce the above copyright | 10 * Redistributions in binary form must reproduce the above copyright |
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 impl = binary_op_noderivs<float, float, float, FUNCTION>; | 1136 impl = binary_op_noderivs<float, float, float, FUNCTION>; |
1137 else if (Result.typespec().is_float() && A.typespec().is_triple()) | 1137 else if (Result.typespec().is_float() && A.typespec().is_triple()) |
1138 impl = binary_op_noderivs<float, Vec3, float, FUNCTION>; | 1138 impl = binary_op_noderivs<float, Vec3, float, FUNCTION>; |
1139 else if (Result.typespec().is_triple() && A.typespec().is_float()) | 1139 else if (Result.typespec().is_triple() && A.typespec().is_float()) |
1140 impl = binary_op_noderivs<Vec3, float, float, FUNCTION>; | 1140 impl = binary_op_noderivs<Vec3, float, float, FUNCTION>; |
1141 else if (Result.typespec().is_triple() && A.typespec().is_triple()) | 1141 else if (Result.typespec().is_triple() && A.typespec().is_triple()) |
1142 impl = binary_op_noderivs<Vec3, Vec3, float, FUNCTION>; | 1142 impl = binary_op_noderivs<Vec3, Vec3, float, FUNCTION>; |
1143 } | 1143 } |
1144 | 1144 |
1145 if (impl) { | 1145 if (impl) { |
1146 impl (exec, nargs, args, runflags, beginpoint, endpoint); | 1146 impl (exec, nargs, args); |
1147 // Use the specialized one for next time! Never have to check the | 1147 // Use the specialized one for next time! Never have to check the |
1148 // types or do the other sanity checks again. | 1148 // types or do the other sanity checks again. |
1149 // FIXME -- is this thread-safe? | 1149 // FIXME -- is this thread-safe? |
1150 exec->op().implementation (impl); | 1150 exec->op().implementation (impl); |
1151 } else { | 1151 } else { |
1152 exec->error_arg_types (); | 1152 exec->error_arg_types (); |
1153 ASSERT (0 && "Function arg type can't be handled"); | 1153 ASSERT (0 && "Function arg type can't be handled"); |
1154 } | 1154 } |
1155 } | 1155 } |
1156 | 1156 |
(...skipping 27 matching lines...) Expand all Loading... |
1184 impl = binary_op<float, float, float, FUNCTION>; | 1184 impl = binary_op<float, float, float, FUNCTION>; |
1185 else if (Result.typespec().is_float() && A.typespec().is_triple()) | 1185 else if (Result.typespec().is_float() && A.typespec().is_triple()) |
1186 impl = binary_op<float, Vec3, float, FUNCTION>; | 1186 impl = binary_op<float, Vec3, float, FUNCTION>; |
1187 else if (Result.typespec().is_triple() && A.typespec().is_float()) | 1187 else if (Result.typespec().is_triple() && A.typespec().is_float()) |
1188 impl = binary_op<Vec3, float, float, FUNCTION>; | 1188 impl = binary_op<Vec3, float, float, FUNCTION>; |
1189 else if (Result.typespec().is_triple() && A.typespec().is_triple()) | 1189 else if (Result.typespec().is_triple() && A.typespec().is_triple()) |
1190 impl = binary_op<Vec3, Vec3, float, FUNCTION>; | 1190 impl = binary_op<Vec3, Vec3, float, FUNCTION>; |
1191 } | 1191 } |
1192 | 1192 |
1193 if (impl) { | 1193 if (impl) { |
1194 impl (exec, nargs, args, runflags, beginpoint, endpoint); | 1194 impl (exec, nargs, args); |
1195 // Use the specialized one for next time! Never have to check the | 1195 // Use the specialized one for next time! Never have to check the |
1196 // types or do the other sanity checks again. | 1196 // types or do the other sanity checks again. |
1197 // FIXME -- is this thread-safe? | 1197 // FIXME -- is this thread-safe? |
1198 exec->op().implementation (impl); | 1198 exec->op().implementation (impl); |
1199 } else { | 1199 } else { |
1200 exec->error_arg_types (); | 1200 exec->error_arg_types (); |
1201 ASSERT (0 && "Function arg type can't be handled"); | 1201 ASSERT (0 && "Function arg type can't be handled"); |
1202 } | 1202 } |
1203 } | 1203 } |
1204 | 1204 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1249 impl = quaternary_op_binary_derivs<float, float, float, float, float
, FUNCTION>; | 1249 impl = quaternary_op_binary_derivs<float, float, float, float, float
, FUNCTION>; |
1250 else if (Result.typespec().is_float() && A.typespec().is_triple()) | 1250 else if (Result.typespec().is_float() && A.typespec().is_triple()) |
1251 impl = quaternary_op_binary_derivs<float, Vec3, float, Vec3, float,
FUNCTION>; | 1251 impl = quaternary_op_binary_derivs<float, Vec3, float, Vec3, float,
FUNCTION>; |
1252 else if (Result.typespec().is_triple() && A.typespec().is_float()) | 1252 else if (Result.typespec().is_triple() && A.typespec().is_float()) |
1253 impl = quaternary_op_binary_derivs<Vec3, float, float, float, float,
FUNCTION>; | 1253 impl = quaternary_op_binary_derivs<Vec3, float, float, float, float,
FUNCTION>; |
1254 else if (Result.typespec().is_triple() && A.typespec().is_triple()) | 1254 else if (Result.typespec().is_triple() && A.typespec().is_triple()) |
1255 impl = quaternary_op_binary_derivs<Vec3, Vec3, float, Vec3, float, F
UNCTION>; | 1255 impl = quaternary_op_binary_derivs<Vec3, Vec3, float, Vec3, float, F
UNCTION>; |
1256 } | 1256 } |
1257 | 1257 |
1258 if (impl) { | 1258 if (impl) { |
1259 impl (exec, nargs, args, runflags, beginpoint, endpoint); | 1259 impl (exec, nargs, args); |
1260 // Use the specialized one for next time! Never have to check the | 1260 // Use the specialized one for next time! Never have to check the |
1261 // types or do the other sanity checks again. | 1261 // types or do the other sanity checks again. |
1262 // FIXME -- is this thread-safe? | 1262 // FIXME -- is this thread-safe? |
1263 exec->op().implementation (impl); | 1263 exec->op().implementation (impl); |
1264 } else { | 1264 } else { |
1265 exec->error_arg_types (); | 1265 exec->error_arg_types (); |
1266 ASSERT (0 && "Function arg type can't be handled"); | 1266 ASSERT (0 && "Function arg type can't be handled"); |
1267 } | 1267 } |
1268 } | 1268 } |
1269 | 1269 |
1270 | 1270 |
1271 | 1271 |
1272 DECLOP (OP_cellnoise) | 1272 DECLOP (OP_cellnoise) |
1273 { | 1273 { |
1274 // NOTE: cellnoise is a step function which is locally flat | 1274 // NOTE: cellnoise is a step function which is locally flat |
1275 // therefore its derivatives are always 0 | 1275 // therefore its derivatives are always 0 |
1276 generic_noise_function_noderivs<CellNoise> (exec, nargs, args, | 1276 generic_noise_function_noderivs<CellNoise> (exec, nargs, args); |
1277 runflags, beginpoint, endpoint); | |
1278 } | 1277 } |
1279 | 1278 |
1280 | 1279 |
1281 | 1280 |
1282 DECLOP (OP_noise) | 1281 DECLOP (OP_noise) |
1283 { | 1282 { |
1284 generic_noise_function<Noise> (exec, nargs, args, | 1283 generic_noise_function<Noise> (exec, nargs, args); |
1285 runflags, beginpoint, endpoint); | |
1286 } | 1284 } |
1287 | 1285 |
1288 | 1286 |
1289 | 1287 |
1290 DECLOP (OP_snoise) | 1288 DECLOP (OP_snoise) |
1291 { | 1289 { |
1292 generic_noise_function<SNoise> (exec, nargs, args, | 1290 generic_noise_function<SNoise> (exec, nargs, args); |
1293 runflags, beginpoint, endpoint); | |
1294 } | 1291 } |
1295 | 1292 |
1296 | 1293 |
1297 | 1294 |
1298 DECLOP (OP_pnoise) | 1295 DECLOP (OP_pnoise) |
1299 { | 1296 { |
1300 generic_pnoise_function<PeriodicNoise> (exec, nargs, args, | 1297 generic_pnoise_function<PeriodicNoise> (exec, nargs, args); |
1301 runflags, beginpoint, endpoint); | |
1302 } | 1298 } |
1303 | 1299 |
1304 | 1300 |
1305 | 1301 |
1306 DECLOP (OP_psnoise) | 1302 DECLOP (OP_psnoise) |
1307 { | 1303 { |
1308 generic_pnoise_function<PeriodicSNoise> (exec, nargs, args, | 1304 generic_pnoise_function<PeriodicSNoise> (exec, nargs, args); |
1309 runflags, beginpoint, endpoint); | |
1310 } | 1305 } |
1311 | 1306 |
1312 | 1307 |
1313 }; // namespace pvt | 1308 }; // namespace pvt |
1314 }; // namespace OSL | 1309 }; // namespace OSL |
1315 #ifdef OSL_NAMESPACE | 1310 #ifdef OSL_NAMESPACE |
1316 }; // end namespace OSL_NAMESPACE | 1311 }; // end namespace OSL_NAMESPACE |
1317 #endif | 1312 #endif |
1318 | 1313 |
1319 #if 0 // only when testing the statistics of perlin noise to normalize the range | 1314 #if 0 // only when testing the statistics of perlin noise to normalize the range |
(...skipping 30 matching lines...) Expand all Loading... |
1350 noise_avg2 += noise * noise; | 1345 noise_avg2 += noise * noise; |
1351 } | 1346 } |
1352 noise_avg /= n; | 1347 noise_avg /= n; |
1353 noise_stddev = std::sqrt((noise_avg2 - noise_avg * noise_avg * n) / n); | 1348 noise_stddev = std::sqrt((noise_avg2 - noise_avg * noise_avg * n) / n); |
1354 printf("Result: perlin-%d noise stats:\n\tmin: %.17g\n\tmax: %.17g\n\tavg: %
.17g\n\tdev: %.17g\n", | 1349 printf("Result: perlin-%d noise stats:\n\tmin: %.17g\n\tmax: %.17g\n\tavg: %
.17g\n\tdev: %.17g\n", |
1355 d, noise_min, noise_max, noise_avg, noise_stddev); | 1350 d, noise_min, noise_max, noise_avg, noise_stddev); |
1356 printf("Normalization: %.17g\n", 1.0f / std::max(fabsf(noise_min), fabsf(noi
se_max))); | 1351 printf("Normalization: %.17g\n", 1.0f / std::max(fabsf(noise_min), fabsf(noi
se_max))); |
1357 } | 1352 } |
1358 | 1353 |
1359 #endif | 1354 #endif |
OLD | NEW |