AVSim/simulation-package
Simulation runtime: the third-party half of the AVSim data generation package This repository holds the third-party runtime of the Simulation data generation package, version 3: the pieces the pipeline needs that were not written by the authors. It contains no code and no data of the authors. It is not usable on its own: the private half of the package, AVSim/simulation, downloads this repository into the same directory at a pinned revision with its fetch_runtime.sh script and… See the full description on the dataset page: https://huggingface.co/datasets/AVSim/simulation-package.
03.7k
1/******************************************************************************2<<<<<<< .mine3 * Copyright 2024 NVIDIA Corporation. All rights reserved. *4||||||| .r3747485 * Copyright 2023 NVIDIA Corporation. All rights reserved. *6=======7 * Copyright 2024 NVIDIA Corporation. All rights reserved. *8>>>>>>> .r3767839 ******************************************************************************10 11Permission is hereby granted by NVIDIA Corporation ("NVIDIA"), free of charge,12to any person obtaining a copy of the sample definition code that uses our 13Material Definition Language (the "MDL Materials"), to reproduce and distribute14the MDL Materials, including without limitation the rights to use, copy, merge,15publish, distribute, and sell modified and unmodified copies of the MDL 16Materials, and to permit persons to whom the MDL Materials is furnished to do17so, in all cases solely for use with NVIDIA's Material Definition Language,18subject to the following further conditions:19 201. The above copyright notices, this list of conditions, and the disclaimer21that follows shall be retained in all copies of one or more of the MDL22Materials, including in any software with which the MDL Materials are bundled,23redistributed, and/or sold, and included either as stand-alone text files,24human-readable headers or in the appropriate machine-readable metadata fields25within text or binary files as long as those fields can be easily viewed by the26user, as applicable.272. The name of NVIDIA shall not be used to promote, endorse or advertise any 28Modified Version without specific prior written permission, except a) to comply29 with the notice requirements otherwise contained herein; or b) to acknowledge30the contribution(s) of NVIDIA.31 32THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS33OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,34FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,35TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR 36ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, 37INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF 38CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE39THE MDL MATERIALS OR FROM OTHER DEALINGS IN THE MDL MATERIALS.40*/41 42 43mdl 1.7;44 45import ::anno::*;46import ::base::*;47import ::df::*;48import ::math::*;49import ::state::*;50import ::tex::*;51import ::nvidia::core_definitions::*;52 53const string COPYRIGHT = 54" Copyright 2024 NVIDIA Corporation. All rights reserved.\n"55" MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,\n"56" WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,\n" 57" THE MDL MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n"58" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF\n"59" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF\n" 60" COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA\n"61" CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY\n"62" GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN\n"63" AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR\n"64" INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN THE MDL MATERIALS.\n";65 66 67enum unit_scale{68 unit_mm = 1,69 unit_cm = 2,70 unit_m = 371};72 73float histogram_range(float input, float range = 1.0f, float position = 0.5f)74{ 75 float low = ::math::clamp(1.0 - ::math::min(((1.0 - position) + range * 0.5), (1.0 - position) * 2), 0.0, 1.0);76 float high = ::math::clamp(math::min((position + range * 0.5 ), position * 2.0), 0.0, 1.0);77 return ::math::lerp(low, high, input);78}79 80float remap_xy_to_0_1(float input, float x, float y)81{82 return (input - x)/(y - x);83}84 85float histogram_scan_small(float input, float width, float position)86{ 87 return ::math::clamp(88 remap_xy_to_0_1(input,89 position * (1.0f - width), // special case of ::math::lerp(0.0, 1.0 - width, position),90 ::math::lerp(width, 1.0 , position)),91 0.0,92 1.0);93}94 95struct volume_info{96 color absorption_coefficient;97 color scattering_coefficient;98};99 100 101volume_info volume_transmittance_albedo(102 float density_scale = 1.0,103 color transmittance = color(0.5f), // transmittance color after unit distance104 color albedo = color(1.0f)105)106[[107 anno::noinline()108]]109{110 color sigma_t = -math::log(math::saturate(transmittance)) * density_scale;111 color sigma_s = sigma_t * ::math::saturate(albedo);112 return volume_info(113 scattering_coefficient: sigma_s,114 absorption_coefficient: sigma_t - sigma_s);115}116 117volume_info custom_volume_transmittance(118 unit_scale unit_scale_select = unit_mm,119 float absorption_thickness = 3.0f,120 color transmittance = color(0.5f),121 color albedo = color(0.0f)122)123{124 absorption_thickness = (absorption_thickness <= 0.0f) ? 0.00001 : absorption_thickness;125 float scalefactor;126 switch(unit_scale_select){127 case unit_mm: scalefactor = 0.001f; break;128 case unit_cm: scalefactor = 0.01f; break;129 case unit_m: scalefactor = 1.0f; break;130 default: scalefactor = 1.0f;131 }132 133 134 135 volume_info vol_coefficients = volume_transmittance_albedo(136 density_scale: 1.0f/(absorption_thickness * scalefactor),137 transmittance: transmittance,138 albedo: albedo139 );140 141 return vol_coefficients;142}143 144float3 rgb2hsl(float3 c)145[[146 ::anno::description("Converts a color value to HSL. The function outputs the hue to \n"147 "lie in the range from 0.0-1.0."),148 ::anno::author("NVIDIA vMaterials")149]]150{151 float3 hsl;152 float cMax = ::math::max(::math::max(c.x, c.y), c.z);153 float cMin = ::math::min(::math::min(c.x, c.y), c.z);154 float delta = cMax - cMin;155 156 hsl.z = (cMax + cMin) / 2.0; 157 hsl.x = ((cMax == cMin) ? 0 :158 (cMax == c.x) ? (c.y - c.z) / delta + ((c.z > c.y) ? 6.0f : 0.0f):159 (cMax == c.y) ? (c.z - c.x) / delta + 2.0 : (c.x - c.y) / delta + 4.0) / 6.0f;160 hsl.y = (hsl.z == 0.0 || hsl.z == 1.0) ? 0.0 : delta / (1.0 - ::math::abs(2.0 * hsl.z - 1.0));161 return hsl;162}163 164 165// converts a HSL value back to a color166// The Hue is expected to lie in the range 167float f_n(float n, float a, float h, float l) {168 float k = ::math::fmod(n + h * 12.f, 12.f);169 170 return l - a * ::math::max(-1.0f, ::math::min(::math::min(k-3.0f, 9.0f-k), 1.0f));171}172 173color hsl2rgb(float3 hsl)174[[175 ::anno::description("Converts a HSL value back to a color. Note that the hue is expected to \n"176 "lie in the range from 0.0-1.0."),177 ::anno::author("NVIDIA vMaterials")178]]179{180 float h = hsl.x, s = hsl.y, l = hsl.z;181 float a = s * ::math::min(l, 1.0f - l);182 return color(f_n(0.0, a, h, l),183 f_n(8.0, a, h, l),184 f_n(4.0, a, h, l)); 185}186 187struct vm_coordinates{188 float2 uv; // UV coordinates stored as a simple float2189 float rotation; // The rotation is stored in radiands (not degress), to convert use ((rotation* 3.1415926535897932384626433832f) / 180.f)190 int uv_space_index; // The UV space Index from which the UV data came from191 float4 carry; // may carry additional data, such as random IDs192};193 194struct vm_3float{195 float x;196 float y;197 float z;198};199 200enum vm_mono_select 201[[202 anno::description("Modes for the creation of a gray-scale value from a color."),203 anno::hidden()204]]205{206 mono_r = 0,207 mono_g = 1,208 mono_b = 2,209 mono_a = 3,210 mono_average = 4211};212 213vm_coordinates vm_coord214(215 float2 translation = float2(0.0f, 0.0) [[216 ::anno::display_name("Translation"),217 ::anno::description("Translates the coordinates.")218 ]],219 float rotation = 0.0f [[220 ::anno::display_name("Rotation"),221 ::anno::description("Rotates the coordinates in degrees.")222 ]],223 float2 scaling = float2(1.0f, 1.0f) [[224 ::anno::display_name("Scaling"),225 ::anno::description("Scales the coordinates.")226 ]], 227 uniform int uv_space = 0 [[228 ::anno::display_name("UV Space"),229 ::anno::description("Chose the UV space.")230 ]]231)232[[233 ::anno::display_name("vm Transform"),234 ::anno::description("Generates coordinates to be used in vm_lookup functions.")235]]236{237 vm_coordinates uv;238 ::base::texture_coordinate_info info = ::base::coordinate_source( ::base::texture_coordinate_uvw, uv_space);239 uv.rotation = (rotation * 3.1415926535897932384626433832f) / 180.f;240 uv.uv = float2(info.position.x, info.position.y);241 float sine = ::math::sin(uv.rotation);242 float cosine = ::math::cos(uv.rotation);243 float2x2 rot = float2x2(cosine, -sine, sine, cosine);244 uv.uv = rot * uv.uv;245 uv.uv /= scaling;246 uv.uv += translation;247 // Translation before or after rotation?248 return uv;249}250 251vm_coordinates vm_coord_post_rotate(252 vm_coordinates uv = vm_coord() [[253 ::anno::display_name("VM Coordinates"),254 ::anno::description("A set of vm coordinates.")255 ]],256 float rotation = 0.0f [[257 ::anno::display_name("Rotation"),258 ::anno::description("Rotates the coordinates in degrees.")259 ]]260)261{262 float rot_rad = (rotation * 3.1415926535897932384626433832f) / 180.f; // track rotation263 float sine = ::math::sin(rot_rad);264 float cosine = ::math::cos(rot_rad);265 float2x2 rot = float2x2(cosine, -sine, sine, cosine);266 267 uv.rotation += rot_rad;268 uv.uv = rot * uv.uv;269 return uv;270}271 272 273 274vm_coordinates vm_coord_post_scale(275 vm_coordinates uv = vm_coord(),276 float2 scale = float2(1.0f)277)278{279 uv.uv /= scale;280 return uv;281}282 283::base::texture_return vm_tex_lookup(284 uniform texture_2d tex,285 vm_coordinates uv = vm_coord(),286 uniform vm_mono_select mono_source = mono_a,287 float4 scale = float4(1.0f))288{289 float mono;290 float4 lookup = ::tex::lookup_float4(tex, uv.uv, ::tex::wrap_repeat, ::tex::wrap_repeat) * scale;291 switch( mono_source ) {292 case mono_r: mono = lookup.x;293 break;294 case mono_g: mono = lookup.y;295 break;296 case mono_b: mono = lookup.z;297 break;298 case mono_a: mono = lookup.w;299 break;300 case mono_average: mono = ::math::average(float3(lookup.x, lookup.y, lookup.z));301 break;302 }303 return ::base::texture_return(color(lookup.x, lookup.y, lookup.z), mono);304}305 306vm_3float vm_tex_lookup_3float(307 uniform texture_2d tex,308 vm_coordinates uv = vm_coord(),309 float3 scale = float3(1.0f))310{311 vm_3float ret;312 float3 lookup = ::tex::lookup_float3(tex, uv.uv, ::tex::wrap_repeat, ::tex::wrap_repeat) * scale;313 ret.x = lookup.x;314 ret.y = lookup.y;315 ret.z = lookup.z;316 return ret;317}318 319float3 vm_tex_normal_lookup_2x(320 uniform texture_2d tex_a,321 uniform texture_2d tex_b,322 vm_coordinates uv_a = vm_coord(),323 vm_coordinates uv_b = vm_coord(),324 float strength_a = 1.0f,325 float strength_b = 1.0f,326 bool use_coord_a_only = false // when set to 'false, tex_b share coordinates from 'uv_a'327)328{329 float rot_a = uv_a.rotation;330 float rot_b = use_coord_a_only ? uv_a.rotation : uv_b.rotation;331 uv_b.uv = use_coord_a_only ? uv_a.uv : uv_b.uv;332 333 // Lookup and convert normal textures a and b to -1 ... 1 range334 float3 norm_a = (::tex::lookup_float3(tex_a, uv_a.uv, ::tex::wrap_repeat, ::tex::wrap_repeat) - float3(.5f)) * 2.0f;335 norm_a = ::math::normalize(norm_a * float3(strength_a, strength_a, 1.0));336 float3 norm_b = (::tex::lookup_float3(tex_b, uv_b.uv, ::tex::wrap_repeat, ::tex::wrap_repeat) - float3(.5f)) * 2.0f;337 norm_b = ::math::normalize(norm_b * float3(strength_b, strength_b, 1.0));338 339 // if any rotation happened prior to the lookup, compensate for it340 norm_a = float3(::math::cos(rot_a) * norm_a.x - ::math::sin(rot_a) * norm_a.y,341 ::math::sin(rot_a) * norm_a.x + ::math::cos(rot_a) * norm_a.y,342 norm_a.z);343 norm_b = float3(::math::cos(rot_b) * norm_b.x - ::math::sin(rot_b) * norm_b.y,344 ::math::sin(rot_b) * norm_b.x + ::math::cos(rot_b) * norm_b.y,345 norm_b.z);346 347 // http://blog.selfshadow.com/publications/blending-in-detail/348 norm_a=norm_a + float3(0.,0.,1.);349 norm_b = norm_b * float3(-1.,-1.,1.);350 float3 norm = norm_a*math::dot(norm_a, norm_b)/norm_a.z - norm_b;351 352 return norm.x * ::state::texture_tangent_u(uv_a.uv_space_index) +353 norm.y * ::state::texture_tangent_v(uv_a.uv_space_index) +354 norm.z * ::state::normal();355}356 357 358//359export material Turquoise(360 color transmission_color = color (0.296138f, 1.000000f, 0.904661) //( 0.2392157f , 0.8039216f , 0.7294118f)361 [[362 ::anno::display_name("Transmission Color"),363 ::anno::description("Color effect for transmission independent of thickness of the object."),364 ::anno::in_group("Appearance")365 ]],366 uniform color volume_color = color(0.009721f, 0.693872f, 0.693872f) //( 0.001f , 0.01188235f , 0.01188235f)367 [[368 ::anno::display_name("Volume Color"),369 ::anno::description("Color effect for volume of the object reached at transmission distance."),370 ::anno::in_group("Appearance")371 ]],372 uniform color crack_color = color(0.023153f, 0.011612f, 0.001f) // ( 0.02352941f , 0.01176471f , 0.f)373 [[374 ::anno::display_name("Crack Color"),375 ::anno::description("Color of cracks."),376 ::anno::in_group("Appearance")377 ]],378 uniform color flake_color = color (1.000000f, 0.527115f, 0.001f) //( 1.f , 0.5294118f , 0.f)379 [[380 ::anno::display_name("Flake Color"),381 ::anno::description("Color of flakes."),382 ::anno::in_group("Appearance")383 ]],384 uniform float clarity = .15f385 [[386 ::anno::display_name("Clarity"),387 ::anno::description("Use to adapt to size of object."),388 ::anno::soft_range(0.1,10.0),389 ::anno::in_group("Appearance")390 ]],391 uniform float flake_size = 1.f392 [[393 ::anno::display_name("Flake Size"),394 ::anno::description("Determines size of flakes (in mm)."),395 ::anno::in_group("Appearance")396 ]],397 uniform float flake_amount = 1.f398 [[399 ::anno::display_name("Flake Amount"),400 ::anno::description("Determines amount of visible flakes."),401 ::anno::soft_range(0.0,1.0),402 ::anno::in_group("Appearance")403 ]],404 uniform texture_2d crack_texture = texture_2d ( "./textures/turquoise_crack_msk.png" , ::tex::gamma_srgb)405 [[406 ::anno::display_name("Crack Texture"),407 ::anno::description("Attach map of cracks here."),408 ::anno::in_group("Appearance")409 ]],410 uniform float3 texture_translate = float3 ( 0.f)411 [[412 ::anno::display_name("Translate"),413 ::anno::description("Controls the position of the texture."),414 ::anno::in_group("Transform")415 ]],416 uniform float texture_rotate = 0.f417 [[418 ::anno::display_name("Rotate"),419 ::anno::description("Rotate angle in degrees."),420 ::anno::in_group("Transform")421 ]],422 uniform float2 texture_scale = float2 ( 1.f)423 [[424 ::anno::display_name("Scale"),425 ::anno::description("Larger numbers increase the texture size."),426 ::anno::in_group("Transform"),427 ::nvidia::core_definitions::dimension(float2(1.0f, 1.0f))428 ]],429 uniform int uv_space_index = 0430 [[431 ::anno::display_name("UV Space Index"),432 ::anno::description("UV space index."),433 ::anno::hard_range(0,3),434 ::anno::in_group("Advanced")435 ]])436[[437 ::anno::display_name("Turquoise"),438 ::anno::description("Turquoise gem material (Default values based on 2cm stone size.)"),439 ::anno::author("NVIDIA vMaterials"),440 ::anno::contributor("Rüdiger Raab"),441 ::anno::contributor("Maik Rohland"),442 ::anno::copyright_notice(COPYRIGHT),443 ::anno::thumbnail("./.thumbs/Turquoise.Turquoise.png"),444 ::anno::hidden(),445 ::anno::key_words(string[]("gem", "jewelry", "gemstone", "transmissive", "new", "design", "turquoise", "cool"))446]]= 447::nvidia::core_definitions::add_globalbump(448 base: ::nvidia::core_definitions::blend(449 base: ::nvidia::core_definitions::thick_translucent(450 transmission_color: ::nvidia::core_definitions::perlin_noise_texture(451 color1: transmission_color,452 color2: color ( 1.f , 1.f , 1.f),453 object_space: true,454 noise_levels: 3,455 absolute_noise: false,456 noise_threshold_high: 1.f,457 noise_threshold_low: 0.f,458 scaling: float3 ( 300.f , 300.f , 300.f),459 translation: texture_translate,460 rotation: float3 (texture_rotate,texture_rotate,texture_rotate),461 texture_space: uv_space_index).tint,462 volume_color: volume_color,463 volume_scattering: 0.99999f,464 roughness: 0.f,465 reflectivity: 1.f,466 base_thickness: clarity * 0.1f,467 normal: ::state::normal (),468 ior: 1.65f),469 blend: ::nvidia::core_definitions::apply_metallicflakes(470 base: ::nvidia::core_definitions::flex_material(471 base_color: crack_color,472 diffuse_roughness: 0.f,473 is_metal: false,474 reflectivity: 0.3f,475 reflection_roughness: 0.2f,476 anisotropy: 0.f,477 anisotropy_rotation: 0.f,478 transparency: 0.f,479 transmission_color: color ( 1.f , 1.f , 1.f),480 volume_color: color ( 1.f , 1.f , 1.f),481 transmission_roughness: 0.f,482 base_thickness: clarity * 0.1f,483 ior: 1.5f,484 thin_walled: false,485 normal: ::state::normal ()),486 flake_color: flake_color,487 roughness: 0.f,488 size: flake_size * 0.1f,489 amount: flake_amount * 0.15f,490 opacity: 0.5f,491 bump: 1.f),492 weight: ::nvidia::core_definitions::file_texture(493 texture: crack_texture,494 mono_source: ::base::mono_average,495 brightness: 1.f,496 contrast: 1.f,497 scaling: 1.f / texture_scale,498 translation: float2 (texture_translate.x, texture_translate.y) ,499 rotation: texture_rotate,500 clip: false,501 texture_space: uv_space_index,502 invert: false).mono),503 normal: ::nvidia::core_definitions::file_bump_texture(504 texture: crack_texture,505 bump_source: ::base::mono_luminance,506 scaling: 1.f / texture_scale,507 translation: float2 (texture_translate.x, texture_translate.y) ,508 rotation: texture_rotate,509 clip: false,510 factor: -0.2f,511 texture_space: uv_space_index));512 513 514export material Turquoise_Mineral(515 float turquoise_tint = 1.0f [[516 ::anno::description("Adjusts the color of the mineral from greenish to blueish."),517 ::anno::display_name("Tint"),518 ::anno::in_group("Appearance"),519 ::anno::soft_range(0.f, 1.f),520 ::anno::hard_range(0.f, 1.f),521 ::anno::ui_order(0)522 ]],523 float diffuse_brightness = 0.6f [[524 ::anno::description("Adjusts the lightness of the material."),525 ::anno::display_name("Brightness"),526 ::anno::in_group("Appearance"),527 ::anno::soft_range(0.f, 1.f),528 ::anno::hard_range(0.f, 1.f),529 ::anno::ui_order(1)530 ]],531 float polishing_roughness = 0.26f [[532 ::anno::description("Higher roughness values lead to bigger highlights and blurrier reflections."),533 ::anno::display_name("Roughness"),534 ::anno::in_group("Appearance"),535 ::anno::soft_range(0.f, 1.f),536 ::anno::hard_range(0.f, 1.f),537 ::anno::ui_order(2)538 ]],539 color veins_color = color(0.158961f, 0.090842f, 0.017642f) [[540 ::anno::description("Adjusts the color of the veins."),541 ::anno::display_name("Vein Color"),542 ::anno::in_group("Appearance"),543 ::anno::ui_order(3)544 ]],545 float veins_big_amount = 1.f [[546 ::anno::description("Controls the visibility of the large veins in the material."),547 ::anno::display_name("Large Veins"),548 ::anno::in_group("Appearance"),549 ::anno::soft_range(0.f, 1.f),550 ::anno::hard_range(0.f, 1.f),551 ::anno::ui_order(4)552 ]],553 float veins_small_amount = 0.52f [[554 ::anno::description("Controls the visibility of the small veins in the material."),555 ::anno::display_name("Small Veins"),556 ::anno::in_group("Appearance"),557 ::anno::soft_range(0.f, 1.f),558 ::anno::hard_range(0.f, 1.f),559 ::anno::ui_order(5)560 ]],561 float veins_breakup = 0.f [[562 ::anno::description("Breaks up the veins, so that they appear and disappear at different positions through the material."),563 ::anno::display_name("Veins Breakup"),564 ::anno::in_group("Appearance"),565 ::anno::soft_range(0.f, 1.f),566 ::anno::hard_range(0.f, 1.f),567 ::anno::ui_order(6)568 ]],569 float veins_bump_strength = 0.03f [[570 ::anno::description("Controls the strength of the veins that appear on the mineral surface."),571 ::anno::display_name("Veins Bump Strength"),572 ::anno::in_group("Appearance"),573 ::anno::soft_range(0.f, 1.f),574 ::anno::hard_range(0.f, 2.f),575 ::anno::ui_order(7)576 ]],577 float2 texture_translate = float2(0.0f, 0.0f) [[578 ::anno::description("Controls the position of the texture."),579 ::anno::display_name("Texture Translate"),580 ::anno::in_group("Transform"),581 ::anno::ui_order(8)582 ]],583 float texture_rotate = 0.f [[584 ::anno::description("Rotates angle of the texture in degrees."),585 ::anno::display_name("Texture Rotate"),586 ::anno::in_group("Transform"),587 ::anno::soft_range(0.f, 360.f),588 ::anno::ui_order(9)589 ]],590 float2 texture_scale = float2(1.0f) [[591 ::anno::description("Larger numbers increase the size."),592 ::anno::display_name("Texture Scale"),593 ::anno::in_group("Transform"),594 ::nvidia::core_definitions::dimension(float2(0.04f, 0.04f)),595 ::anno::ui_order(10)596 ]],597 uniform int uv_space_index = 0 [[598 ::anno::description("Uses selected UV space for material."),599 ::anno::display_name("UV Space Index"),600 ::anno::in_group("Transform"),601 ::anno::ui_order(11)602 ]],603 uniform bool roundcorners_enable = false [[604 ::anno::description("Enables the round corner effect. Comes at a slight performance cost as additional raytracing calls are required to evaluate the round corner effect."),605 ::anno::display_name("Enable Round Corners"),606 ::anno::in_group("Round Corners"),607 ::anno::ui_order(12)608 ]],609 uniform float roundcorners_radius_mm = 1.0f [[610 ::anno::description("Radius of the rounded corners in millimeters."),611 ::anno::display_name("Round Corner Radius (mm)"),612 ::anno::in_group("Round Corners"),613 ::anno::soft_range(0.f, 10.f),614 ::anno::ui_order(13)615 ]],616 uniform bool roundcorners_across_materials = false [[617 ::anno::description("Applies the round corner effect across different materials when enabled."),618 ::anno::display_name("Across Materials"),619 ::anno::in_group("Round Corners."),620 ::anno::ui_order(14)621 ]])622[[623 ::anno::display_name("Turquoise - Sky Blue"),624 ::anno::description("Turquoise gem material with adjustable color hue and veins."),625 ::anno::author("NVIDIA vMaterials"),626 ::anno::contributor("Rüdiger Raab"),627 ::anno::contributor("Maik Rohland"),628 ::anno::copyright_notice(COPYRIGHT),629 ::anno::thumbnail("./.thumbs/Turquoise.Turquoise_Mineral.png"),630 ::anno::key_words(string[]("gem", "jewelry", "gemstone", "SSS", "transmissive", "new", "design", "turquoise", "blue", "cool", "saturated"))631]]632 = 633 let {634 bool tmp0 = false;635 636 texture_2d multi_rough_tex = texture_2d("./textures/turquoise_multi_rough.jpg", ::tex::gamma_linear);637 texture_2d veins_tex = texture_2d("./textures/turquoise_veins.jpg", ::tex::gamma_linear);638 texture_2d breakup_tex = texture_2d("./textures/turquoise_breakup_noise.png", ::tex::gamma_linear);639 texture_2d diff_lin_tex = texture_2d("./textures/turquoise_diffuse.jpg", ::tex::gamma_linear);640 texture_2d norm_tex = texture_2d("./textures/turquoise_cracks_norm2.jpg", ::tex::gamma_linear);641 642 643 material_surface tmp1(::df::custom_curve_layer(0.0399999991f, 1.f, 5.f, 1.f, ::df::microfacet_ggx_smith_bsdf(::math::lerp(histogram_range(vm_tex_lookup_3float(multi_rough_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float3(1.f)).x * 0.620000005f + vm_tex_lookup_3float(multi_rough_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float3(1.f)).y, 0.75999999f, polishing_roughness * 0.5f), ::math::lerp(histogram_range(vm_tex_lookup_3float(multi_rough_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float3(1.f)).x * 0.620000005f + vm_tex_lookup_3float(multi_rough_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float3(1.f)).y, 0.75999999f, polishing_roughness * 0.5f), 0.75f, histogram_scan_small(nvidia::core_definitions::blend_colors(nvidia::core_definitions::blend_colors(vm_tex_lookup(veins_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), mono_a, float4(veins_big_amount)).tint, vm_tex_lookup(breakup_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), mono_a, float4(1.f)).tint, ::base::color_layer_multiply, veins_breakup, true).tint, nvidia::core_definitions::blend_colors(vm_tex_lookup(veins_tex, vm_coord_post_scale(vm_coord_post_rotate(vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), 0.74000001f), float2(0.5f)), mono_a, float4(veins_small_amount)).tint, vm_tex_lookup(breakup_tex, vm_coord_post_scale(vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float2(0.5f)), mono_a, float4(1.f)).tint, ::base::color_layer_multiply, veins_breakup, true).tint, ::base::color_layer_screen, 1.f, true).mono, 0.620000005f, 0.119999997f)), veins_bump_strength) * ::math::lerp(histogram_range(vm_tex_lookup_3float(multi_rough_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float3(1.f)).x * 0.620000005f + vm_tex_lookup_3float(multi_rough_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float3(1.f)).y, 0.75999999f, polishing_roughness * 0.5f), ::math::lerp(histogram_range(vm_tex_lookup_3float(multi_rough_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float3(1.f)).x * 0.620000005f + vm_tex_lookup_3float(multi_rough_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float3(1.f)).y, 0.75999999f, polishing_roughness * 0.5f), 0.75f, histogram_scan_small(nvidia::core_definitions::blend_colors(nvidia::core_definitions::blend_colors(vm_tex_lookup(veins_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), mono_a, float4(veins_big_amount)).tint, vm_tex_lookup(breakup_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), mono_a, float4(1.f)).tint, ::base::color_layer_multiply, veins_breakup, true).tint, nvidia::core_definitions::blend_colors(vm_tex_lookup(veins_tex, vm_coord_post_scale(vm_coord_post_rotate(vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), 0.74000001f), float2(0.5f)), mono_a, float4(veins_small_amount)).tint, vm_tex_lookup(breakup_tex, vm_coord_post_scale(vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float2(0.5f)), mono_a, float4(1.f)).tint, ::base::color_layer_multiply, veins_breakup, true).tint, ::base::color_layer_screen, 1.f, true).mono, 0.620000005f, 0.119999997f)), veins_bump_strength), ::math::lerp(histogram_range(vm_tex_lookup_3float(multi_rough_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float3(1.f)).x * 0.620000005f + vm_tex_lookup_3float(multi_rough_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float3(1.f)).y, 0.75999999f, polishing_roughness * 0.5f), ::math::lerp(histogram_range(vm_tex_lookup_3float(multi_rough_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float3(1.f)).x * 0.620000005f + vm_tex_lookup_3float(multi_rough_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float3(1.f)).y, 0.75999999f, polishing_roughness * 0.5f), 0.75f, histogram_scan_small(nvidia::core_definitions::blend_colors(nvidia::core_definitions::blend_colors(vm_tex_lookup(veins_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), mono_a, float4(veins_big_amount)).tint, vm_tex_lookup(breakup_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), mono_a, float4(1.f)).tint, ::base::color_layer_multiply, veins_breakup, true).tint, nvidia::core_definitions::blend_colors(vm_tex_lookup(veins_tex, vm_coord_post_scale(vm_coord_post_rotate(vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), 0.74000001f), float2(0.5f)), mono_a, float4(veins_small_amount)).tint, vm_tex_lookup(breakup_tex, vm_coord_post_scale(vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float2(0.5f)), mono_a, float4(1.f)).tint, ::base::color_layer_multiply, veins_breakup, true).tint, ::base::color_layer_screen, 1.f, true).mono, 0.620000005f, 0.119999997f)), veins_bump_strength) * ::math::lerp(histogram_range(vm_tex_lookup_3float(multi_rough_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float3(1.f)).x * 0.620000005f + vm_tex_lookup_3float(multi_rough_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float3(1.f)).y, 0.75999999f, polishing_roughness * 0.5f), ::math::lerp(histogram_range(vm_tex_lookup_3float(multi_rough_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float3(1.f)).x * 0.620000005f + vm_tex_lookup_3float(multi_rough_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float3(1.f)).y, 0.75999999f, polishing_roughness * 0.5f), 0.75f, histogram_scan_small(nvidia::core_definitions::blend_colors(nvidia::core_definitions::blend_colors(vm_tex_lookup(veins_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), mono_a, float4(veins_big_amount)).tint, vm_tex_lookup(breakup_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), mono_a, float4(1.f)).tint, ::base::color_layer_multiply, veins_breakup, true).tint, nvidia::core_definitions::blend_colors(vm_tex_lookup(veins_tex, vm_coord_post_scale(vm_coord_post_rotate(vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), 0.74000001f), float2(0.5f)), mono_a, float4(veins_small_amount)).tint, vm_tex_lookup(breakup_tex, vm_coord_post_scale(vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float2(0.5f)), mono_a, float4(1.f)).tint, ::base::color_layer_multiply, veins_breakup, true).tint, ::base::color_layer_screen, 1.f, true).mono, 0.620000005f, 0.119999997f)), veins_bump_strength), color(1.f, 1.f, 1.f), color(0.f, 0.f, 0.f), ::state::texture_tangent_u(0), ::df::scatter_reflect), ::df::weighted_layer(0.589999974f, ::df::diffuse_reflection_bsdf(::math::pow(nvidia::core_definitions::blend_colors(hsl2rgb(rgb2hsl(float3(vm_tex_lookup(diff_lin_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), mono_a, float4(1.f)).tint)) + float3((turquoise_tint - 1.f) * 0.159999996f, 0.f, 0.f)), veins_color, ::base::color_layer_blend, nvidia::core_definitions::blend_colors(nvidia::core_definitions::blend_colors(vm_tex_lookup(veins_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), mono_a, float4(veins_big_amount)).tint, vm_tex_lookup(breakup_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), mono_a, float4(1.f)).tint, ::base::color_layer_multiply, veins_breakup, true).tint, nvidia::core_definitions::blend_colors(vm_tex_lookup(veins_tex, vm_coord_post_scale(vm_coord_post_rotate(vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), 0.74000001f), float2(0.5f)), mono_a, float4(veins_small_amount)).tint, vm_tex_lookup(breakup_tex, vm_coord_post_scale(vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float2(0.5f)), mono_a, float4(1.f)).tint, ::base::color_layer_multiply, veins_breakup, true).tint, ::base::color_layer_screen, 1.f, true).mono, true).tint, diffuse_brightness * -2.5999999f + 3.79999995f), 0.f), ::df::weighted_layer(1.f, ::df::diffuse_transmission_bsdf(color(0.768150985f, 0.944563985f, 1.f)), bsdf(), vm_tex_normal_lookup_2x(norm_tex, norm_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), vm_coord_post_scale(vm_coord_post_rotate(vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), 0.74000001f), float2(0.5f)), nvidia::core_definitions::blend_colors(vm_tex_lookup(veins_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), mono_a, float4(veins_big_amount)).tint, vm_tex_lookup(breakup_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), mono_a, float4(1.f)).tint, ::base::color_layer_multiply, veins_breakup, true).mono * (veins_bump_strength * 10.f), nvidia::core_definitions::blend_colors(vm_tex_lookup(veins_tex, vm_coord_post_scale(vm_coord_post_rotate(vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), 0.74000001f), float2(0.5f)), mono_a, float4(veins_small_amount)).tint, vm_tex_lookup(breakup_tex, vm_coord_post_scale(vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float2(0.5f)), mono_a, float4(1.f)).tint, ::base::color_layer_multiply, veins_breakup, true).mono * (veins_bump_strength * 10.f), false)), vm_tex_normal_lookup_2x(norm_tex, norm_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), vm_coord_post_scale(vm_coord_post_rotate(vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), 0.74000001f), float2(0.5f)), nvidia::core_definitions::blend_colors(vm_tex_lookup(veins_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), mono_a, float4(veins_big_amount)).tint, vm_tex_lookup(breakup_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), mono_a, float4(1.f)).tint, ::base::color_layer_multiply, veins_breakup, true).mono * (veins_bump_strength * 10.f), nvidia::core_definitions::blend_colors(vm_tex_lookup(veins_tex, vm_coord_post_scale(vm_coord_post_rotate(vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), 0.74000001f), float2(0.5f)), mono_a, float4(veins_small_amount)).tint, vm_tex_lookup(breakup_tex, vm_coord_post_scale(vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float2(0.5f)), mono_a, float4(1.f)).tint, ::base::color_layer_multiply, veins_breakup, true).mono * (veins_bump_strength * 10.f), false)), vm_tex_normal_lookup_2x(norm_tex, norm_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), vm_coord_post_scale(vm_coord_post_rotate(vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), 0.74000001f), float2(0.5f)), nvidia::core_definitions::blend_colors(vm_tex_lookup(veins_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), mono_a, float4(veins_big_amount)).tint, vm_tex_lookup(breakup_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), mono_a, float4(1.f)).tint, ::base::color_layer_multiply, veins_breakup, true).mono * (veins_bump_strength * 10.f), nvidia::core_definitions::blend_colors(vm_tex_lookup(veins_tex, vm_coord_post_scale(vm_coord_post_rotate(vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), 0.74000001f), float2(0.5f)), mono_a, float4(veins_small_amount)).tint, vm_tex_lookup(breakup_tex, vm_coord_post_scale(vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), float2(0.5f)), mono_a, float4(1.f)).tint, ::base::color_layer_multiply, veins_breakup, true).mono * (veins_bump_strength * 10.f), false)), material_emission(emission: edf(), intensity: color(0.f, 0.f, 0.f), mode: intensity_radiant_exitance));644 material_surface tmp2 = material_surface(scattering: bsdf(), emission: material_emission(emission: edf(), intensity: color(0.f, 0.f, 0.f), mode: intensity_radiant_exitance));645 color tmp3 = color(1.f, 1.f, 1.f);646 material_volume tmp4(647 vdf(),648 custom_volume_transmittance(unit_cm, 3.f, color(0.0331959985f, 0.0975869969f, 0.0886309966f), hsl2rgb(rgb2hsl(float3(vm_tex_lookup(diff_lin_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), mono_a, float4(1.f)).tint)) + float3((turquoise_tint - 1.f) * 0.159999996f, 0.f, 0.f))).absorption_coefficient,649 custom_volume_transmittance(unit_cm, 3.f, color(0.0331959985f, 0.0975869969f, 0.0886309966f), hsl2rgb(rgb2hsl(float3(vm_tex_lookup(diff_lin_tex, vm_coord(texture_translate, texture_rotate, texture_scale, uv_space_index), mono_a, float4(1.f)).tint)) + float3((turquoise_tint - 1.f) * 0.159999996f, 0.f, 0.f))).scattering_coefficient,650 color(0.f, 0.f, 0.f));651 material_geometry tmp5(float3(0.f), 1.f, roundcorners_enable ? ::state::rounded_corner_normal(roundcorners_radius_mm * 0.00100000005f, roundcorners_across_materials, 1.f) : ::state::normal());652 } in653 material(654 thin_walled: tmp0,655 surface: tmp1,656 backface: tmp2,657 ior: tmp3,658 volume: tmp4,659 geometry: tmp5);660 661 662// 2 663export material Turquoise_Blueish_Green(*)664[[665 ::anno::display_name("Turquoise - Medium Blue"),666 ::anno::description("Turquoise gem material with adjustable color hue and veins."),667 ::anno::author("NVIDIA vMaterials"),668 ::anno::contributor("Rüdiger Raab"),669 ::anno::contributor("Maik Rohland"),670 ::anno::copyright_notice(COPYRIGHT),671 ::anno::thumbnail("./.thumbs/Turquoise.Turquoise_Blueish_Green.png"),672 ::anno::key_words(string[]("gem", "jewelry", "gemstone", "SSS", "transmissive", "new", "design", "bumped", "turquoise", "medium", "blue", "cool", "saturated"))673]] = Turquoise_Mineral(674 turquoise_tint: 0.66f,675 diffuse_brightness: 0.6f,676 polishing_roughness: 0.35f,677 veins_color: color(0.158961f, 0.090842f, 0.017642f),678 veins_big_amount: 1.0f,679 veins_small_amount: 0.81f,680 veins_breakup: 0.5f,681 veins_bump_strength: 1.0f,682 texture_translate: float2(0.0f),683 texture_rotate: 0.0f,684 texture_scale: float2(1.0f),685 uv_space_index: 0,686 roundcorners_enable: false,687 roundcorners_radius_mm: 1.0f,688 roundcorners_across_materials: false689);690 691 692// 3693export material Turquoise_Apple_Green(*)694[[695 ::anno::display_name("Turquoise - Apple Green"),696 ::anno::description("Turquoise gem material with adjustable color hue and veins."),697 ::anno::author("NVIDIA vMaterials"),698 ::anno::contributor("Rüdiger Raab"),699 ::anno::contributor("Maik Rohland"),700 ::anno::copyright_notice(COPYRIGHT),701 ::anno::thumbnail("./.thumbs/Turquoise.Turquoise_Apple_Green.png"),702 ::anno::key_words(string[]("gem", "jewelry", "gemstone", "SSS", "transmissive", "new", "design", "bumped", "rough", "turquoise", "blue", "apple", "green", "cool", "saturated"))703]] = Turquoise_Mineral(704 turquoise_tint: 0.0f,705 diffuse_brightness: 0.6f,706 polishing_roughness: 0.79f,707 veins_color: color(0.158961f, 0.090842f, 0.017642f),708 veins_big_amount: 1.0f,709 veins_small_amount: 0.81f,710 veins_breakup: 0.5f,711 veins_bump_strength: 1.0f,712 texture_translate: float2(0.0f),713 texture_rotate: 0.0f,714 texture_scale: float2(1.0f),715 uv_space_index: 0,716 roundcorners_enable: false,717 roundcorners_radius_mm: 1.0f,718 roundcorners_across_materials: false719);