Datasets:

ArXiv:
License:
File size: 9,406 Bytes
ae81f33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/******************************************************************************
 *          Copyright 2024 NVIDIA Corporation. All rights reserved.           *
 ******************************************************************************
 
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.6;

import ::anno::*;
import ::df::*;
import ::base::*;
import ::math::*;
import ::nvidia::core_definitions::apply_colorfalloff;
import ::nvidia::core_definitions::thick_glass;
import ::state::normal;

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";

/*
bsdf apply_colorfalloff_v2(
    material base = scratched_metal_v2(metal_color: color(1.)),
    uniform color color_0 = color(1.,0.,0.),
    uniform color color_1 = color(0.,1.,0.),
    uniform color color_2 = color(0.,0.,1.),
    uniform color color_3 = color(1.,0.,0.),
    uniform color color_4 = color(0.,1.,0.)
)
 =  material(
    surface: material_surface(
        scattering: df::measured_curve_factor(
            curve_values: color[](color_0,color_1,color_2,color_3,color_4),
            base: base.surface.scattering
        ),
        emission: base.surface.emission
    ),
    volume: base.volume,
    ior: base.ior,
    thin_walled: base.thin_walled,
    geometry: base.geometry
);


material gem_definition(
	color transmission_color = color(1.0),
    uniform color glass_color = color(.95),
    float roughness = 0.0,
    uniform float volume_ior = 1.4f,
    uniform bool dispersion = true,
    uniform float abbe_number = 1.4f,
    uniform float base_thickness = .1,
    float3 normal = ::state::normal()
)
[[
	::anno::hidden()
]]
 = let{
	 
    bsdf glossy_bsdf = ::df::simple_glossy_bsdf(
        mode: ::df::scatter_reflect,
        tint: color(1.),
        roughness_u: roughness
    );
    bsdf glossy_bsdf_transmission = ::df::simple_glossy_bsdf(
        mode: ::df::scatter_transmit,
        tint: transmission_color,
        roughness_u: roughness
    );
	
	bsdf surface_bsdf = ::df::weighted_layer(
            normal: normal,
            weight: 1.,
            layer: ::df::color_fresnel_layer(
                layer: glossy_bsdf,
                base: glossy_bsdf_transmission,
                ior: dispersion?::base::abbe_number_ior(volume_ior, abbe_number):color(volume_ior)
            )
        );
		
} in material(
    thin_walled: false,
    surface: material_surface(scattering: surface_bsdf ),
    volume: material_volume(
        absorption_coefficient: (base_thickness <= 0)? color(0): ::math::log(glass_color) / -base_thickness
    ),
    ior: dispersion?::base::abbe_number_ior(volume_ior, abbe_number):color(volume_ior)
);
*/

export material Diamond(
    color transmission_color = color ( 1.f , 1.f , 1.f)
    [[
        ::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 ( 1.f , 1.f , 1.f)
    [[
        ::anno::display_name("Volume Color"),
        ::anno::description("Color effect for volume of the object reached at transmission distance."),
        ::anno::in_group("Appearance")
    ]],
    uniform float clarity =  1.f
    [[
        ::anno::display_name("Clarity"),
        ::anno::description("Use to adapt to size of gem, smaller numbers darken the gem."),
        ::anno::soft_range(0.1,10.0),
        ::anno::in_group("Appearance")
    ]],
    uniform bool dispersion = true
    [[
        ::anno::display_name("Dispersion"),
        ::anno::description("Enable or disable the dispersion."),
        ::anno::in_group("Advanced")
    ]])
[[
    ::anno::display_name("Diamond"),
    ::anno::description("Diamond 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/Diamond.Diamond.png"),
	::anno::key_words(string[]("gem", "jewelry", "gemstone", "transmissive", "new", "design", "transparent", "diamond", "purple"))
]] = 
let{
	// Gem definition
	// uniform color glass_color = color(.95),
	float roughness = 0.0;
	float volume_ior = 2.42f;
	float abbe_number = 55.f;
	float base_thickness = clarity * 0.1f;
	// float3 normal = ::state::normal()

	bsdf glossy_bsdf = ::df::simple_glossy_bsdf(
        mode: ::df::scatter_reflect,
        tint: color(1.),
        roughness_u: roughness
    );
    bsdf glossy_bsdf_transmission = ::df::simple_glossy_bsdf(
        mode: ::df::scatter_transmit,
        tint: transmission_color,
        roughness_u: roughness
    );
	
	bsdf surface_bsdf = ::df::weighted_layer(
            //normal: normal, // is state::normal anyways, can be omitted
            weight: 1.,
            layer: ::df::color_fresnel_layer(
                layer: glossy_bsdf,
                base: glossy_bsdf_transmission,
                ior: dispersion?::base::abbe_number_ior(volume_ior, abbe_number):color(volume_ior)
            )
    );
	
	bsdf falloff_bsdf =  df::measured_curve_factor(
            curve_values: color[](color( 0.9529412f , 0.972549f , 1.f),
								color( 1.f , 0.9529412f , 0.9960784f),
								color( 0.9529412f , 0.9764706f , 1.f),
								color( 0.9529412f , 1.f , 0.9960784f),
								color( 1.f , 0.9529412f , 0.9843137f)
								),
            base: surface_bsdf
	);
	

	// the apply color falloff function does nothing but add a color gradient while keeping the material'sample
	// other properties
	
	/*
	::nvidia::core_definitions::apply_colorfalloff(
    base:  gem_definition(
        transmission_color:  transmission_color, 	// CHECK
        glass_color:  volume_color,					// CHECK		was modified in the material+_colume expresion	
        roughness:  0.f,							// CHECK				
        volume_ior:  2.42F, 						// CHECK
        dispersion: dispersion,						// CHECK
        abbe_number: 55.f,							// CHECK
        base_thickness:  clarity * 0.1f,			// CHECK
        normal:  ::state::normal ()),				// CHECK
    color_0:  color( 0.9529412f , 0.972549f , 1.f),	// CHECK
    color_1:  color( 1.f , 0.9529412f , 0.9960784f),// CHECK
    color_2:  color( 0.9529412f , 0.9764706f , 1.f),// CHECK
    color_3:  color( 0.9529412f , 1.f , 0.9960784f),// CHECK
    color_4:  color( 1.f , 0.9529412f , 0.9843137f));// CHECK
	*/
	
} in material(
    thin_walled: false,
    surface: material_surface(scattering: falloff_bsdf ),
    volume: material_volume(
        absorption_coefficient: (base_thickness <= 0)? color(0): ::math::log(volume_color) / -base_thickness
    ),
    ior: dispersion?::base::abbe_number_ior(volume_ior, abbe_number):color(volume_ior)
);