| /****************************************************************************** | |
| <<<<<<< .mine | |
| * Copyright 2024 NVIDIA Corporation. All rights reserved. * | |
| ||||||| .r374748 | |
| * Copyright 2023 NVIDIA Corporation. All rights reserved. * | |
| ======= | |
| * Copyright 2024 NVIDIA Corporation. All rights reserved. * | |
| >>>>>>> .r376783 | |
| ****************************************************************************** | |
| Permission is hereby granted by NVIDIA Corporation ("NVIDIA"), free of charge, | |
| to any person obtaining a copy of the sample definition code that uses our | |
| Material Definition Language (the "MDL Materials"), to reproduce and distribute | |
| the MDL Materials, including without limitation the rights to use, copy, merge, | |
| publish, distribute, and sell modified and unmodified copies of the MDL | |
| Materials, and to permit persons to whom the MDL Materials is furnished to do | |
| so, in all cases solely for use with NVIDIA's Material Definition Language, | |
| subject to the following further conditions: | |
| 1. The above copyright notices, this list of conditions, and the disclaimer | |
| that follows shall be retained in all copies of one or more of the MDL | |
| Materials, including in any software with which the MDL Materials are bundled, | |
| redistributed, and/or sold, and included either as stand-alone text files, | |
| human-readable headers or in the appropriate machine-readable metadata fields | |
| within text or binary files as long as those fields can be easily viewed by the | |
| user, as applicable. | |
| 2. The name of NVIDIA shall not be used to promote, endorse or advertise any | |
| Modified Version without specific prior written permission, except a) to comply | |
| with the notice requirements otherwise contained herein; or b) to acknowledge | |
| the contribution(s) of NVIDIA. | |
| THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
| OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, | |
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, | |
| TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR | |
| ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, | |
| INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF | |
| CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE | |
| THE MDL MATERIALS OR FROM OTHER DEALINGS IN THE MDL MATERIALS. | |
| */ | |
| mdl 1.7; | |
| import ::anno::*; | |
| import ::base::*; | |
| import ::df::*; | |
| import ::math::*; | |
| import ::state::*; | |
| import ::tex::*; | |
| import ::nvidia::core_definitions::*; | |
| const string COPYRIGHT = | |
| " Copyright 2024 NVIDIA Corporation. All rights reserved.\n" | |
| " MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,\n" | |
| " WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,\n" | |
| " THE MDL MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n" | |
| " EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF\n" | |
| " MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF\n" | |
| " COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA\n" | |
| " CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY\n" | |
| " GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN\n" | |
| " AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR\n" | |
| " INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN THE MDL MATERIALS.\n"; | |
| enum unit_scale{ | |
| unit_mm = 1, | |
| unit_cm = 2, | |
| unit_m = 3 | |
| }; | |
| float histogram_range(float input, float range = 1.0f, float position = 0.5f) | |
| { | |
| float low = ::math::clamp(1.0 - ::math::min(((1.0 - position) + range * 0.5), (1.0 - position) * 2), 0.0, 1.0); | |
| float high = ::math::clamp(math::min((position + range * 0.5 ), position * 2.0), 0.0, 1.0); | |
| return ::math::lerp(low, high, input); | |
| } | |
| float remap_xy_to_0_1(float input, float x, float y) | |
| { | |
| return (input - x)/(y - x); | |
| } | |
| float histogram_scan_small(float input, float width, float position) | |
| { | |
| return ::math::clamp( | |
| remap_xy_to_0_1(input, | |
| position * (1.0f - width), // special case of ::math::lerp(0.0, 1.0 - width, position), | |
| ::math::lerp(width, 1.0 , position)), | |
| 0.0, | |
| 1.0); | |
| } | |
| struct volume_info{ | |
| color absorption_coefficient; | |
| color scattering_coefficient; | |
| }; | |
| volume_info volume_transmittance_albedo( | |
| float density_scale = 1.0, | |
| color transmittance = color(0.5f), // transmittance color after unit distance | |
| color albedo = color(1.0f) | |
| ) | |
| [[ | |
| anno::noinline() | |
| ]] | |
| { | |
| color sigma_t = -math::log(math::saturate(transmittance)) * density_scale; | |
| color sigma_s = sigma_t * ::math::saturate(albedo); | |
| return volume_info( | |
| scattering_coefficient: sigma_s, | |
| absorption_coefficient: sigma_t - sigma_s); | |
| } | |
| volume_info custom_volume_transmittance( | |
| unit_scale unit_scale_select = unit_mm, | |
| float absorption_thickness = 3.0f, | |
| color transmittance = color(0.5f), | |
| color albedo = color(0.0f) | |
| ) | |
| { | |
| absorption_thickness = (absorption_thickness <= 0.0f) ? 0.00001 : absorption_thickness; | |
| float scalefactor; | |
| switch(unit_scale_select){ | |
| case unit_mm: scalefactor = 0.001f; break; | |
| case unit_cm: scalefactor = 0.01f; break; | |
| case unit_m: scalefactor = 1.0f; break; | |
| default: scalefactor = 1.0f; | |
| } | |
| volume_info vol_coefficients = volume_transmittance_albedo( | |
| density_scale: 1.0f/(absorption_thickness * scalefactor), | |
| transmittance: transmittance, | |
| albedo: albedo | |
| ); | |
| return vol_coefficients; | |
| } | |
| float3 rgb2hsl(float3 c) | |
| [[ | |
| ::anno::description("Converts a color value to HSL. The function outputs the hue to \n" | |
| "lie in the range from 0.0-1.0."), | |
| ::anno::author("NVIDIA vMaterials") | |
| ]] | |
| { | |
| float3 hsl; | |
| float cMax = ::math::max(::math::max(c.x, c.y), c.z); | |
| float cMin = ::math::min(::math::min(c.x, c.y), c.z); | |
| float delta = cMax - cMin; | |
| hsl.z = (cMax + cMin) / 2.0; | |
| hsl.x = ((cMax == cMin) ? 0 : | |
| (cMax == c.x) ? (c.y - c.z) / delta + ((c.z > c.y) ? 6.0f : 0.0f): | |
| (cMax == c.y) ? (c.z - c.x) / delta + 2.0 : (c.x - c.y) / delta + 4.0) / 6.0f; | |
| hsl.y = (hsl.z == 0.0 || hsl.z == 1.0) ? 0.0 : delta / (1.0 - ::math::abs(2.0 * hsl.z - 1.0)); | |
| return hsl; | |
| } | |
| // converts a HSL value back to a color | |
| // The Hue is expected to lie in the range | |
| float f_n(float n, float a, float h, float l) { | |
| float k = ::math::fmod(n + h * 12.f, 12.f); | |
| return l - a * ::math::max(-1.0f, ::math::min(::math::min(k-3.0f, 9.0f-k), 1.0f)); | |
| } | |
| color hsl2rgb(float3 hsl) | |
| [[ | |
| ::anno::description("Converts a HSL value back to a color. Note that the hue is expected to \n" | |
| "lie in the range from 0.0-1.0."), | |
| ::anno::author("NVIDIA vMaterials") | |
| ]] | |
| { | |
| float h = hsl.x, s = hsl.y, l = hsl.z; | |
| float a = s * ::math::min(l, 1.0f - l); | |
| return color(f_n(0.0, a, h, l), | |
| f_n(8.0, a, h, l), | |
| f_n(4.0, a, h, l)); | |
| } | |
| struct vm_coordinates{ | |
| float2 uv; // UV coordinates stored as a simple float2 | |
| float rotation; // The rotation is stored in radiands (not degress), to convert use ((rotation* 3.1415926535897932384626433832f) / 180.f) | |
| int uv_space_index; // The UV space Index from which the UV data came from | |
| float4 carry; // may carry additional data, such as random IDs | |
| }; | |
| struct vm_3float{ | |
| float x; | |
| float y; | |
| float z; | |
| }; | |
| enum vm_mono_select | |
| [[ | |
| anno::description("Modes for the creation of a gray-scale value from a color."), | |
| anno::hidden() | |
| ]] | |
| { | |
| mono_r = 0, | |
| mono_g = 1, | |
| mono_b = 2, | |
| mono_a = 3, | |
| mono_average = 4 | |
| }; | |
| vm_coordinates vm_coord | |
| ( | |
| float2 translation = float2(0.0f, 0.0) [[ | |
| ::anno::display_name("Translation"), | |
| ::anno::description("Translates the coordinates.") | |
| ]], | |
| float rotation = 0.0f [[ | |
| ::anno::display_name("Rotation"), | |
| ::anno::description("Rotates the coordinates in degrees.") | |
| ]], | |
| float2 scaling = float2(1.0f, 1.0f) [[ | |
| ::anno::display_name("Scaling"), | |
| ::anno::description("Scales the coordinates.") | |
| ]], | |
| uniform int uv_space = 0 [[ | |
| ::anno::display_name("UV Space"), | |
| ::anno::description("Chose the UV space.") | |
| ]] | |
| ) | |
| [[ | |
| ::anno::display_name("vm Transform"), | |
| ::anno::description("Generates coordinates to be used in vm_lookup functions.") | |
| ]] | |
| { | |
| vm_coordinates uv; | |
| ::base::texture_coordinate_info info = ::base::coordinate_source( ::base::texture_coordinate_uvw, uv_space); | |
| uv.rotation = (rotation * 3.1415926535897932384626433832f) / 180.f; | |
| uv.uv = float2(info.position.x, info.position.y); | |
| float sine = ::math::sin(uv.rotation); | |
| float cosine = ::math::cos(uv.rotation); | |
| float2x2 rot = float2x2(cosine, -sine, sine, cosine); | |
| uv.uv = rot * uv.uv; | |
| uv.uv /= scaling; | |
| uv.uv += translation; | |
| // Translation before or after rotation? | |
| return uv; | |
| } | |
| vm_coordinates vm_coord_post_rotate( | |
| vm_coordinates uv = vm_coord() [[ | |
| ::anno::display_name("VM Coordinates"), | |
| ::anno::description("A set of vm coordinates.") | |
| ]], | |
| float rotation = 0.0f [[ | |
| ::anno::display_name("Rotation"), | |
| ::anno::description("Rotates the coordinates in degrees.") | |
| ]] | |
| ) | |
| { | |
| float rot_rad = (rotation * 3.1415926535897932384626433832f) / 180.f; // track rotation | |
| float sine = ::math::sin(rot_rad); | |
| float cosine = ::math::cos(rot_rad); | |
| float2x2 rot = float2x2(cosine, -sine, sine, cosine); | |
| uv.rotation += rot_rad; | |
| uv.uv = rot * uv.uv; | |
| return uv; | |
| } | |
| vm_coordinates vm_coord_post_scale( | |
| vm_coordinates uv = vm_coord(), | |
| float2 scale = float2(1.0f) | |
| ) | |
| { | |
| uv.uv /= scale; | |
| return uv; | |
| } | |
| ::base::texture_return vm_tex_lookup( | |
| uniform texture_2d tex, | |
| vm_coordinates uv = vm_coord(), | |
| uniform vm_mono_select mono_source = mono_a, | |
| float4 scale = float4(1.0f)) | |
| { | |
| float mono; | |
| float4 lookup = ::tex::lookup_float4(tex, uv.uv, ::tex::wrap_repeat, ::tex::wrap_repeat) * scale; | |
| switch( mono_source ) { | |
| case mono_r: mono = lookup.x; | |
| break; | |
| case mono_g: mono = lookup.y; | |
| break; | |
| case mono_b: mono = lookup.z; | |
| break; | |
| case mono_a: mono = lookup.w; | |
| break; | |
| case mono_average: mono = ::math::average(float3(lookup.x, lookup.y, lookup.z)); | |
| break; | |
| } | |
| return ::base::texture_return(color(lookup.x, lookup.y, lookup.z), mono); | |
| } | |
| vm_3float vm_tex_lookup_3float( | |
| uniform texture_2d tex, | |
| vm_coordinates uv = vm_coord(), | |
| float3 scale = float3(1.0f)) | |
| { | |
| vm_3float ret; | |
| float3 lookup = ::tex::lookup_float3(tex, uv.uv, ::tex::wrap_repeat, ::tex::wrap_repeat) * scale; | |
| ret.x = lookup.x; | |
| ret.y = lookup.y; | |
| ret.z = lookup.z; | |
| return ret; | |
| } | |
| float3 vm_tex_normal_lookup_2x( | |
| uniform texture_2d tex_a, | |
| uniform texture_2d tex_b, | |
| vm_coordinates uv_a = vm_coord(), | |
| vm_coordinates uv_b = vm_coord(), | |
| float strength_a = 1.0f, | |
| float strength_b = 1.0f, | |
| bool use_coord_a_only = false // when set to 'false, tex_b share coordinates from 'uv_a' | |
| ) | |
| { | |
| float rot_a = uv_a.rotation; | |
| float rot_b = use_coord_a_only ? uv_a.rotation : uv_b.rotation; | |
| uv_b.uv = use_coord_a_only ? uv_a.uv : uv_b.uv; | |
| // Lookup and convert normal textures a and b to -1 ... 1 range | |
| float3 norm_a = (::tex::lookup_float3(tex_a, uv_a.uv, ::tex::wrap_repeat, ::tex::wrap_repeat) - float3(.5f)) * 2.0f; | |
| norm_a = ::math::normalize(norm_a * float3(strength_a, strength_a, 1.0)); | |
| float3 norm_b = (::tex::lookup_float3(tex_b, uv_b.uv, ::tex::wrap_repeat, ::tex::wrap_repeat) - float3(.5f)) * 2.0f; | |
| norm_b = ::math::normalize(norm_b * float3(strength_b, strength_b, 1.0)); | |
| // if any rotation happened prior to the lookup, compensate for it | |
| norm_a = float3(::math::cos(rot_a) * norm_a.x - ::math::sin(rot_a) * norm_a.y, | |
| ::math::sin(rot_a) * norm_a.x + ::math::cos(rot_a) * norm_a.y, | |
| norm_a.z); | |
| norm_b = float3(::math::cos(rot_b) * norm_b.x - ::math::sin(rot_b) * norm_b.y, | |
| ::math::sin(rot_b) * norm_b.x + ::math::cos(rot_b) * norm_b.y, | |
| norm_b.z); | |
| // http://blog.selfshadow.com/publications/blending-in-detail/ | |
| norm_a=norm_a + float3(0.,0.,1.); | |
| norm_b = norm_b * float3(-1.,-1.,1.); | |
| float3 norm = norm_a*math::dot(norm_a, norm_b)/norm_a.z - norm_b; | |
| return norm.x * ::state::texture_tangent_u(uv_a.uv_space_index) + | |
| norm.y * ::state::texture_tangent_v(uv_a.uv_space_index) + | |
| norm.z * ::state::normal(); | |
| } | |
| // | |
| export material Turquoise( | |
| color transmission_color = color (0.296138f, 1.000000f, 0.904661) //( 0.2392157f , 0.8039216f , 0.7294118f) | |
| [[ | |
| ::anno::display_name("Transmission Color"), | |
| ::anno::description("Color effect for transmission independent of thickness of the object."), | |
| ::anno::in_group("Appearance") | |
| ]], | |
| uniform color volume_color = color(0.009721f, 0.693872f, 0.693872f) //( 0.001f , 0.01188235f , 0.01188235f) | |
| [[ | |
| ::anno::display_name("Volume Color"), | |
| ::anno::description("Color effect for volume of the object reached at transmission distance."), | |
| ::anno::in_group("Appearance") | |
| ]], | |
| uniform color crack_color = color(0.023153f, 0.011612f, 0.001f) // ( 0.02352941f , 0.01176471f , 0.f) | |
| [[ | |
| ::anno::display_name("Crack Color"), | |
| ::anno::description("Color of cracks."), | |
| ::anno::in_group("Appearance") | |
| ]], | |
| uniform color flake_color = color (1.000000f, 0.527115f, 0.001f) //( 1.f , 0.5294118f , 0.f) | |
| [[ | |
| ::anno::display_name("Flake Color"), | |
| ::anno::description("Color of flakes."), | |
| ::anno::in_group("Appearance") | |
| ]], | |
| uniform float clarity = .15f | |
| [[ | |
| ::anno::display_name("Clarity"), | |
| ::anno::description("Use to adapt to size of object."), | |
| ::anno::soft_range(0.1,10.0), | |
| ::anno::in_group("Appearance") | |
| ]], | |
| uniform float flake_size = 1.f | |
| [[ | |
| ::anno::display_name("Flake Size"), | |
| ::anno::description("Determines size of flakes (in mm)."), | |
| ::anno::in_group("Appearance") | |
| ]], | |
| uniform float flake_amount = 1.f | |
| [[ | |
| ::anno::display_name("Flake Amount"), | |
| ::anno::description("Determines amount of visible flakes."), | |
| ::anno::soft_range(0.0,1.0), | |
| ::anno::in_group("Appearance") | |
| ]], | |
| uniform texture_2d crack_texture = texture_2d ( "./textures/turquoise_crack_msk.png" , ::tex::gamma_srgb) | |
| [[ | |
| ::anno::display_name("Crack Texture"), | |
| ::anno::description("Attach map of cracks here."), | |
| ::anno::in_group("Appearance") | |
| ]], | |
| uniform float3 texture_translate = float3 ( 0.f) | |
| [[ | |
| ::anno::display_name("Translate"), | |
| ::anno::description("Controls the position of the texture."), | |
| ::anno::in_group("Transform") | |
| ]], | |
| uniform float texture_rotate = 0.f | |
| [[ | |
| ::anno::display_name("Rotate"), | |
| ::anno::description("Rotate angle in degrees."), | |
| ::anno::in_group("Transform") | |
| ]], | |
| uniform float2 texture_scale = float2 ( 1.f) | |
| [[ | |
| ::anno::display_name("Scale"), | |
| ::anno::description("Larger numbers increase the texture size."), | |
| ::anno::in_group("Transform"), | |
| ::nvidia::core_definitions::dimension(float2(1.0f, 1.0f)) | |
| ]], | |
| uniform int uv_space_index = 0 | |
| [[ | |
| ::anno::display_name("UV Space Index"), | |
| ::anno::description("UV space index."), | |
| ::anno::hard_range(0,3), | |
| ::anno::in_group("Advanced") | |
| ]]) | |
| [[ | |
| ::anno::display_name("Turquoise"), | |
| ::anno::description("Turquoise gem material (Default values based on 2cm stone size.)"), | |
| ::anno::author("NVIDIA vMaterials"), | |
| ::anno::contributor("Rüdiger Raab"), | |
| ::anno::contributor("Maik Rohland"), | |
| ::anno::copyright_notice(COPYRIGHT), | |
| ::anno::thumbnail("./.thumbs/Turquoise.Turquoise.png"), | |
| ::anno::hidden(), | |
| ::anno::key_words(string[]("gem", "jewelry", "gemstone", "transmissive", "new", "design", "turquoise", "cool")) | |
| ]]= | |
| ::nvidia::core_definitions::add_globalbump( | |
| base: ::nvidia::core_definitions::blend( | |
| base: ::nvidia::core_definitions::thick_translucent( | |
| transmission_color: ::nvidia::core_definitions::perlin_noise_texture( | |
| color1: transmission_color, | |
| color2: color ( 1.f , 1.f , 1.f), | |
| object_space: true, | |
| noise_levels: 3, | |
| absolute_noise: false, | |
| noise_threshold_high: 1.f, | |
| noise_threshold_low: 0.f, | |
| scaling: float3 ( 300.f , 300.f , 300.f), | |
| translation: texture_translate, | |
| rotation: float3 (texture_rotate,texture_rotate,texture_rotate), | |
| texture_space: uv_space_index).tint, | |
| volume_color: volume_color, | |
| volume_scattering: 0.99999f, | |
| roughness: 0.f, | |
| reflectivity: 1.f, | |
| base_thickness: clarity * 0.1f, | |
| normal: ::state::normal (), | |
| ior: 1.65f), | |
| blend: ::nvidia::core_definitions::apply_metallicflakes( | |
| base: ::nvidia::core_definitions::flex_material( | |
| base_color: crack_color, | |
| diffuse_roughness: 0.f, | |
| is_metal: false, | |
| reflectivity: 0.3f, | |
| reflection_roughness: 0.2f, | |
| anisotropy: 0.f, | |
| anisotropy_rotation: 0.f, | |
| transparency: 0.f, | |
| transmission_color: color ( 1.f , 1.f , 1.f), | |
| volume_color: color ( 1.f , 1.f , 1.f), | |
| transmission_roughness: 0.f, | |
| base_thickness: clarity * 0.1f, | |
| ior: 1.5f, | |
| thin_walled: false, | |
| normal: ::state::normal ()), | |
| flake_color: flake_color, | |
| roughness: 0.f, | |
| size: flake_size * 0.1f, | |
| amount: flake_amount * 0.15f, | |
| opacity: 0.5f, | |
| bump: 1.f), | |
| weight: ::nvidia::core_definitions::file_texture( | |
| texture: crack_texture, | |
| mono_source: ::base::mono_average, | |
| brightness: 1.f, | |
| contrast: 1.f, | |
| scaling: 1.f / texture_scale, | |
| translation: float2 (texture_translate.x, texture_translate.y) , | |
| rotation: texture_rotate, | |
| clip: false, | |
| texture_space: uv_space_index, | |
| invert: false).mono), | |
| normal: ::nvidia::core_definitions::file_bump_texture( | |
| texture: crack_texture, | |
| bump_source: ::base::mono_luminance, | |
| scaling: 1.f / texture_scale, | |
| translation: float2 (texture_translate.x, texture_translate.y) , | |
| rotation: texture_rotate, | |
| clip: false, | |
| factor: -0.2f, | |
| texture_space: uv_space_index)); | |
| export material Turquoise_Mineral( | |
| float turquoise_tint = 1.0f [[ | |
| ::anno::description("Adjusts the color of the mineral from greenish to blueish."), | |
| ::anno::display_name("Tint"), | |
| ::anno::in_group("Appearance"), | |
| ::anno::soft_range(0.f, 1.f), | |
| ::anno::hard_range(0.f, 1.f), | |
| ::anno::ui_order(0) | |
| ]], | |
| float diffuse_brightness = 0.6f [[ | |
| ::anno::description("Adjusts the lightness of the material."), | |
| ::anno::display_name("Brightness"), | |
| ::anno::in_group("Appearance"), | |
| ::anno::soft_range(0.f, 1.f), | |
| ::anno::hard_range(0.f, 1.f), | |
| ::anno::ui_order(1) | |
| ]], | |
| float polishing_roughness = 0.26f [[ | |
| ::anno::description("Higher roughness values lead to bigger highlights and blurrier reflections."), | |
| ::anno::display_name("Roughness"), | |
| ::anno::in_group("Appearance"), | |
| ::anno::soft_range(0.f, 1.f), | |
| ::anno::hard_range(0.f, 1.f), | |
| ::anno::ui_order(2) | |
| ]], | |
| color veins_color = color(0.158961f, 0.090842f, 0.017642f) [[ | |
| ::anno::description("Adjusts the color of the veins."), | |
| ::anno::display_name("Vein Color"), | |
| ::anno::in_group("Appearance"), | |
| ::anno::ui_order(3) | |
| ]], | |
| float veins_big_amount = 1.f [[ | |
| ::anno::description("Controls the visibility of the large veins in the material."), | |
| ::anno::display_name("Large Veins"), | |
| ::anno::in_group("Appearance"), | |
| ::anno::soft_range(0.f, 1.f), | |
| ::anno::hard_range(0.f, 1.f), | |
| ::anno::ui_order(4) | |
| ]], | |
| float veins_small_amount = 0.52f [[ | |
| ::anno::description("Controls the visibility of the small veins in the material."), | |
| ::anno::display_name("Small Veins"), | |
| ::anno::in_group("Appearance"), | |
| ::anno::soft_range(0.f, 1.f), | |
| ::anno::hard_range(0.f, 1.f), | |
| ::anno::ui_order(5) | |
| ]], | |
| float veins_breakup = 0.f [[ | |
| ::anno::description("Breaks up the veins, so that they appear and disappear at different positions through the material."), | |
| ::anno::display_name("Veins Breakup"), | |
| ::anno::in_group("Appearance"), | |
| ::anno::soft_range(0.f, 1.f), | |
| ::anno::hard_range(0.f, 1.f), | |
| ::anno::ui_order(6) | |
| ]], | |
| float veins_bump_strength = 0.03f [[ | |
| ::anno::description("Controls the strength of the veins that appear on the mineral surface."), | |
| ::anno::display_name("Veins Bump Strength"), | |
| ::anno::in_group("Appearance"), | |
| ::anno::soft_range(0.f, 1.f), | |
| ::anno::hard_range(0.f, 2.f), | |
| ::anno::ui_order(7) | |
| ]], | |
| float2 texture_translate = float2(0.0f, 0.0f) [[ | |
| ::anno::description("Controls the position of the texture."), | |
| ::anno::display_name("Texture Translate"), | |
| ::anno::in_group("Transform"), | |
| ::anno::ui_order(8) | |
| ]], | |
| float texture_rotate = 0.f [[ | |
| ::anno::description("Rotates angle of the texture in degrees."), | |
| ::anno::display_name("Texture Rotate"), | |
| ::anno::in_group("Transform"), | |
| ::anno::soft_range(0.f, 360.f), | |
| ::anno::ui_order(9) | |
| ]], | |
| float2 texture_scale = float2(1.0f) [[ | |
| ::anno::description("Larger numbers increase the size."), | |
| ::anno::display_name("Texture Scale"), | |
| ::anno::in_group("Transform"), | |
| ::nvidia::core_definitions::dimension(float2(0.04f, 0.04f)), | |
| ::anno::ui_order(10) | |
| ]], | |
| uniform int uv_space_index = 0 [[ | |
| ::anno::description("Uses selected UV space for material."), | |
| ::anno::display_name("UV Space Index"), | |
| ::anno::in_group("Transform"), | |
| ::anno::ui_order(11) | |
| ]], | |
| uniform bool roundcorners_enable = false [[ | |
| ::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."), | |
| ::anno::display_name("Enable Round Corners"), | |
| ::anno::in_group("Round Corners"), | |
| ::anno::ui_order(12) | |
| ]], | |
| uniform float roundcorners_radius_mm = 1.0f [[ | |
| ::anno::description("Radius of the rounded corners in millimeters."), | |
| ::anno::display_name("Round Corner Radius (mm)"), | |
| ::anno::in_group("Round Corners"), | |
| ::anno::soft_range(0.f, 10.f), | |
| ::anno::ui_order(13) | |
| ]], | |
| uniform bool roundcorners_across_materials = false [[ | |
| ::anno::description("Applies the round corner effect across different materials when enabled."), | |
| ::anno::display_name("Across Materials"), | |
| ::anno::in_group("Round Corners."), | |
| ::anno::ui_order(14) | |
| ]]) | |
| [[ | |
| ::anno::display_name("Turquoise - Sky Blue"), | |
| ::anno::description("Turquoise gem material with adjustable color hue and veins."), | |
| ::anno::author("NVIDIA vMaterials"), | |
| ::anno::contributor("Rüdiger Raab"), | |
| ::anno::contributor("Maik Rohland"), | |
| ::anno::copyright_notice(COPYRIGHT), | |
| ::anno::thumbnail("./.thumbs/Turquoise.Turquoise_Mineral.png"), | |
| ::anno::key_words(string[]("gem", "jewelry", "gemstone", "SSS", "transmissive", "new", "design", "turquoise", "blue", "cool", "saturated")) | |
| ]] | |
| = | |
| let { | |
| bool tmp0 = false; | |
| texture_2d multi_rough_tex = texture_2d("./textures/turquoise_multi_rough.jpg", ::tex::gamma_linear); | |
| texture_2d veins_tex = texture_2d("./textures/turquoise_veins.jpg", ::tex::gamma_linear); | |
| texture_2d breakup_tex = texture_2d("./textures/turquoise_breakup_noise.png", ::tex::gamma_linear); | |
| texture_2d diff_lin_tex = texture_2d("./textures/turquoise_diffuse.jpg", ::tex::gamma_linear); | |
| texture_2d norm_tex = texture_2d("./textures/turquoise_cracks_norm2.jpg", ::tex::gamma_linear); | |
| 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)); | |
| material_surface tmp2 = material_surface(scattering: bsdf(), emission: material_emission(emission: edf(), intensity: color(0.f, 0.f, 0.f), mode: intensity_radiant_exitance)); | |
| color tmp3 = color(1.f, 1.f, 1.f); | |
| material_volume tmp4( | |
| vdf(), | |
| 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, | |
| 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, | |
| color(0.f, 0.f, 0.f)); | |
| 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()); | |
| } in | |
| material( | |
| thin_walled: tmp0, | |
| surface: tmp1, | |
| backface: tmp2, | |
| ior: tmp3, | |
| volume: tmp4, | |
| geometry: tmp5); | |
| // 2 | |
| export material Turquoise_Blueish_Green(*) | |
| [[ | |
| ::anno::display_name("Turquoise - Medium Blue"), | |
| ::anno::description("Turquoise gem material with adjustable color hue and veins."), | |
| ::anno::author("NVIDIA vMaterials"), | |
| ::anno::contributor("Rüdiger Raab"), | |
| ::anno::contributor("Maik Rohland"), | |
| ::anno::copyright_notice(COPYRIGHT), | |
| ::anno::thumbnail("./.thumbs/Turquoise.Turquoise_Blueish_Green.png"), | |
| ::anno::key_words(string[]("gem", "jewelry", "gemstone", "SSS", "transmissive", "new", "design", "bumped", "turquoise", "medium", "blue", "cool", "saturated")) | |
| ]] = Turquoise_Mineral( | |
| turquoise_tint: 0.66f, | |
| diffuse_brightness: 0.6f, | |
| polishing_roughness: 0.35f, | |
| veins_color: color(0.158961f, 0.090842f, 0.017642f), | |
| veins_big_amount: 1.0f, | |
| veins_small_amount: 0.81f, | |
| veins_breakup: 0.5f, | |
| veins_bump_strength: 1.0f, | |
| texture_translate: float2(0.0f), | |
| texture_rotate: 0.0f, | |
| texture_scale: float2(1.0f), | |
| uv_space_index: 0, | |
| roundcorners_enable: false, | |
| roundcorners_radius_mm: 1.0f, | |
| roundcorners_across_materials: false | |
| ); | |
| // 3 | |
| export material Turquoise_Apple_Green(*) | |
| [[ | |
| ::anno::display_name("Turquoise - Apple Green"), | |
| ::anno::description("Turquoise gem material with adjustable color hue and veins."), | |
| ::anno::author("NVIDIA vMaterials"), | |
| ::anno::contributor("Rüdiger Raab"), | |
| ::anno::contributor("Maik Rohland"), | |
| ::anno::copyright_notice(COPYRIGHT), | |
| ::anno::thumbnail("./.thumbs/Turquoise.Turquoise_Apple_Green.png"), | |
| ::anno::key_words(string[]("gem", "jewelry", "gemstone", "SSS", "transmissive", "new", "design", "bumped", "rough", "turquoise", "blue", "apple", "green", "cool", "saturated")) | |
| ]] = Turquoise_Mineral( | |
| turquoise_tint: 0.0f, | |
| diffuse_brightness: 0.6f, | |
| polishing_roughness: 0.79f, | |
| veins_color: color(0.158961f, 0.090842f, 0.017642f), | |
| veins_big_amount: 1.0f, | |
| veins_small_amount: 0.81f, | |
| veins_breakup: 0.5f, | |
| veins_bump_strength: 1.0f, | |
| texture_translate: float2(0.0f), | |
| texture_rotate: 0.0f, | |
| texture_scale: float2(1.0f), | |
| uv_space_index: 0, | |
| roundcorners_enable: false, | |
| roundcorners_radius_mm: 1.0f, | |
| roundcorners_across_materials: false | |
| ); |