Ajout du projet Depths sur Git
This commit is contained in:
+199
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// MDL implementation of core types and supporting functions from
|
||||
// MaterialX: An Open Standard for Network-Based CG Object Looks
|
||||
// Document v1.37 REV2, January 19, 2020
|
||||
// and
|
||||
// MaterialX: An Open Standard for Network-Based CG Object Looks
|
||||
// Document v1.37 REV2, January 19, 2020
|
||||
// www.materialx.org
|
||||
// in
|
||||
// NVIDIA Material Definition Language 1.7
|
||||
// Language Specification
|
||||
// Document version 1.7.2, January 17, 2022
|
||||
// www.nvidia.com/mdl
|
||||
|
||||
mdl 1.6;
|
||||
|
||||
import ::math::*;
|
||||
import ::state::*;
|
||||
import ::tex::*;
|
||||
|
||||
// Epsilon value used in float calculations.
|
||||
export const float FLOAT_EPS = 0.000001;
|
||||
|
||||
// MaterialX Data Types
|
||||
// NOTE: We use native MDL types where possible and rely on the translator
|
||||
// to map MaterialX types to MDL types according to this table:
|
||||
//
|
||||
// MaterialX --> MDL
|
||||
// ------------------
|
||||
// integer --> int
|
||||
// boolean --> bool
|
||||
// float --> float
|
||||
// color3 --> color
|
||||
// color4 --> struct color4 (see below)
|
||||
// vector2 --> float2
|
||||
// vector3 --> float3
|
||||
// vector4 --> float4
|
||||
// matrix33 --> float3x3
|
||||
// matrix44 --> float4x4
|
||||
// string --> string, or context specific enums (see below)
|
||||
// filename --> texture_2d, or other repective resource type
|
||||
// geomname --> (N.A.)
|
||||
// <T>array --> T[<N>] (deferred-size arrays)
|
||||
//
|
||||
// NOTE: The type mapping is not bijective, multiple types in MaterialX
|
||||
// map to the same type in MDL, which can impact the translation
|
||||
// of overloaded nodes to not generate mutliple identical definitions.
|
||||
|
||||
// Special struct type for color4
|
||||
export struct color4 {
|
||||
color rgb = color(0.0);
|
||||
float a = 1.0;
|
||||
};
|
||||
|
||||
// NOTE: MDL does not support operator overloading nor custom constructors,
|
||||
// we use constructor-like functions defined here to help the generator
|
||||
// to work with the vector and color types, as well as operator-like
|
||||
// functions for the color4 type.
|
||||
export color4 mk_color4( float v) { return color4( color(v), v);}
|
||||
export color4 mk_color4( float r, float g, float b, float a) { return color4(color(r,g,b), a); }
|
||||
export color4 mk_color4( float3 v) { return color4(color(v.x, v.y, v.z), 1.0); }
|
||||
export color4 mk_color4( float4 v) { return color4(color(v.x, v.y, v.z), v.w); }
|
||||
export color4 mk_color4( color v) { return color4(v, 1.0); }
|
||||
export color4 mk_color4( color v, float a) { return color4(v, a); }
|
||||
export color mk_color3( float r, float g, float b) { return color(r, g, b); }
|
||||
export color mk_color3( float v) { return color(v); }
|
||||
export color mk_color3( float2 v) { return color(v.x, v.y, 0.0); }
|
||||
export color mk_color3( float3 v) { return color(v.x, v.y, v.z); }
|
||||
export color mk_color3( float4 v) { return color(v.x, v.y, v.z); }
|
||||
export color mk_color3( color v) { return v; }
|
||||
export color mk_color3( color4 v) { return v.rgb; }
|
||||
export float3 mk_float3( color4 v) { return float3(v.rgb); }
|
||||
export float4 mk_float4( color4 v) {
|
||||
float3 rgb = float3(v.rgb);
|
||||
return float4(rgb.x, rgb.y, rgb.z, v.a);
|
||||
}
|
||||
|
||||
export color4 mx_add( color4 v1, color4 v2) { return color4(v1.rgb + v2.rgb, v1.a + v2.a); }
|
||||
export color4 mx_add( color4 v1, float v2) { return color4(v1.rgb + v2 , v1.a + v2 ); }
|
||||
export color4 mx_subtract( color4 v1, color4 v2) { return color4(v1.rgb - v2.rgb, v1.a - v2.a); }
|
||||
export color4 mx_subtract( color4 v1, float v2) { return color4(v1.rgb - v2 , v1.a - v2 ); }
|
||||
export color4 mx_multiply( color4 v1, color4 v2) { return color4(v1.rgb * v2.rgb, v1.a * v2.a); }
|
||||
export color4 mx_multiply( color4 v1, float v2) { return color4(v1.rgb * v2 , v1.a * v2 ); }
|
||||
export color4 mx_divide( color4 v1, color4 v2) { return color4(v1.rgb / v2.rgb, v1.a / v2.a); }
|
||||
export color4 mx_divide( color4 v1, float v2) { return color4(v1.rgb / v2 , v1.a / v2 ); }
|
||||
export float mx_mod( float x, float y) { return x - y * math::floor(x/y); }
|
||||
export float2 mx_mod( float2 x, float2 y) { return x - y * math::floor(x/y); }
|
||||
export float3 mx_mod( float3 x, float3 y) { return x - y * math::floor(x/y); }
|
||||
export float4 mx_mod( float4 x, float4 y) { return x - y * math::floor(x/y); }
|
||||
export float2 mx_mod( float2 x, float y) { return mx_mod(x, float2(y,y)); }
|
||||
export float3 mx_mod( float3 x, float y) { return mx_mod(x, float3(y,y,y)); }
|
||||
export float4 mx_mod( float4 x, float y) { return mx_mod(x, float4(y,y,y,y)); }
|
||||
|
||||
// Parameter Expressions and Function Curves
|
||||
// Idea: attach an auxiliary lookup function if an array of frame values is
|
||||
// given in a <valuecurve> attribute
|
||||
export int curve_lookup( int index, int[<N>] values, int min, int max) {
|
||||
return values[::math::clamp( index, min, max) - min];
|
||||
}
|
||||
export float curve_lookup( int index, float[<N>] values, int min, int max) {
|
||||
return values[::math::clamp( index, min, max) - min];
|
||||
}
|
||||
export float2 curve_lookup( int index, float2[<N>] values, int min, int max) {
|
||||
return values[::math::clamp( index, min, max) - min];
|
||||
}
|
||||
export float3 curve_lookup( int index, float3[<N>] values, int min, int max) {
|
||||
return values[::math::clamp( index, min, max) - min];
|
||||
}
|
||||
export float4 curve_lookup( int index, float4[<N>] values, int min, int max) {
|
||||
return values[::math::clamp( index, min, max) - min];
|
||||
}
|
||||
export color curve_lookup( int index, color[<N>] values, int min, int max) {
|
||||
return values[::math::clamp( index, min, max) - min];
|
||||
}
|
||||
|
||||
// Enum selecting address modes for texture nodes, instead of string
|
||||
export enum mx_addressmode_type {
|
||||
mx_addressmode_type_constant,
|
||||
mx_addressmode_type_clamp,
|
||||
mx_addressmode_type_periodic,
|
||||
mx_addressmode_type_mirror
|
||||
};
|
||||
|
||||
// Enum selecting filter modes for texture nodes, instead of string
|
||||
export enum mx_filterlookup_type {
|
||||
mx_filterlookup_type_closest,
|
||||
mx_filterlookup_type_linear,
|
||||
mx_filterlookup_type_cubic
|
||||
};
|
||||
|
||||
// Enum selecting coordinate spaces, instead of string
|
||||
export enum mx_coordinatespace_type {
|
||||
mx_coordinatespace_type_model,
|
||||
mx_coordinatespace_type_object,
|
||||
mx_coordinatespace_type_world
|
||||
};
|
||||
|
||||
// Helper function mapping MaterialX coordinate spaces to MDL coordinate spaces
|
||||
export state::coordinate_space mx_map_space( mx_coordinatespace_type space) {
|
||||
switch (space) {
|
||||
case mx_coordinatespace_type_world:
|
||||
return state::coordinate_world;
|
||||
case mx_coordinatespace_type_object:
|
||||
return state::coordinate_object;
|
||||
default:
|
||||
return state::coordinate_internal;
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function mapping MaterialX coordinate space strings to MDL coordinate spaces
|
||||
export state::coordinate_space mx_map_space( string space) {
|
||||
if (space == "world") {
|
||||
return state::coordinate_world;
|
||||
}
|
||||
else if (space == "object") {
|
||||
return state::coordinate_object;
|
||||
}
|
||||
else {
|
||||
return state::coordinate_internal;
|
||||
}
|
||||
}
|
||||
|
||||
// Support return type structures for the separate[234] types
|
||||
export struct mx_separate2_vector2_type { float outx = 0.0; float outy = 0.0; };
|
||||
export struct mx_separate3_color3_type { float outr = 0.0; float outg = 0.0; float outb = 0.0; };
|
||||
export struct mx_separate3_vector3_type { float outx = 0.0; float outy = 0.0; float outz = 0.0; };
|
||||
export struct mx_separate4_color4_type { float outr = 0.0; float outg = 0.0; float outb = 0.0; float outa = 0.0; };
|
||||
export struct mx_separate4_vector4_type { float outx = 0.0; float outy = 0.0; float outz = 0.0; float outw = 0.0; };
|
||||
|
||||
// Enum for blur filter type, instead of string
|
||||
export enum mx_filter_type {
|
||||
mx_filter_type_box,
|
||||
mx_filter_type_gaussian
|
||||
};
|
||||
|
||||
// Enum selecting microfacet models, instead of string
|
||||
export enum mx_distribution_type {
|
||||
mx_distribution_type_ggx
|
||||
};
|
||||
|
||||
// Custom annotation for MDL function parameters to map between MDL and the original MaterialX graph.
|
||||
// * When added to a paramater, the "name" will contain the path in the MaterialX graph starting
|
||||
// from the root up to the input using `/` as separator.
|
||||
export annotation origin(string name);
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Support functions for HSV <--> RGB color conversions
|
||||
|
||||
mdl 1.6;
|
||||
|
||||
import ::limits::*;
|
||||
import ::math::*;
|
||||
|
||||
// Convert from the HSV color model to the RGB color model
|
||||
export float3 mx_hsvtorgb(float3 hsv) {
|
||||
// from "Color Imaging, Fundamentals and Applications", Reinhard et al., p. 442
|
||||
|
||||
float h = 6.0 * (hsv.x - math::floor(hsv.x));
|
||||
int hi = int(h); // truncate
|
||||
float f = h - float(hi);
|
||||
|
||||
float zy = hsv.z*hsv.y;
|
||||
float a = hsv.z - zy;
|
||||
float b = hsv.z - zy*f;
|
||||
float c = a + zy*f;
|
||||
|
||||
switch(hi) {
|
||||
default:
|
||||
// hue out of [0,1] range...
|
||||
// fall through...
|
||||
case 0:
|
||||
return float3(hsv.z, c, a);
|
||||
case 1:
|
||||
return float3(b, hsv.z, a);
|
||||
case 2:
|
||||
return float3(a, hsv.z, c);
|
||||
case 3:
|
||||
return float3(a, b, hsv.z);
|
||||
case 4:
|
||||
return float3(c, a, hsv.z);
|
||||
case 5:
|
||||
return float3(hsv.z, a, b);
|
||||
}
|
||||
}
|
||||
|
||||
// Convert from the RGB color model to the HSV color model
|
||||
export float3 mx_rgbtohsv(float3 rgb) {
|
||||
// from "Color Imaging, Fundamentals and Applications", Reinhard et al., p. 442
|
||||
// H =
|
||||
// 60*(G-B)/(max-min) if R is max
|
||||
// 60*(2+((B-R)/(max-min))) if G is max
|
||||
// 60*(4+((R-G)/(max-min))) if B if max
|
||||
// and normalize the result by dividing by 360deg
|
||||
// S = (max-min)/max
|
||||
// V = max
|
||||
|
||||
float max = math::max(rgb.x, math::max(rgb.y, rgb.z));
|
||||
float min = math::min(rgb.x, math::min(rgb.y, rgb.z));
|
||||
float range = max - min;
|
||||
float inv_range = (1.0f/6.0f)/range;
|
||||
|
||||
float saturation = (max > limits::FLOAT_MIN) ? (range / max) : 0.0f;
|
||||
float hue = (saturation != 0.0f) ?
|
||||
((max == rgb.x) ? ((rgb.y-rgb.z)*inv_range) // R is max
|
||||
: (max == rgb.y) ? ((2.0f/6.0f) + (rgb.z-rgb.x)*inv_range) // G is max
|
||||
: ((4.0f/6.0f) + (rgb.x-rgb.y)*inv_range)) // B is max
|
||||
: 0.0f; // hue is undefined (assume 0)
|
||||
|
||||
return float3((hue >= 0.0f) ? hue : (hue + 1.0f), saturation, max);
|
||||
}
|
||||
+760
@@ -0,0 +1,760 @@
|
||||
//
|
||||
// Copyright Contributors to the MaterialX Project
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
/********************************************************************************
|
||||
MaterialX Noise Library.
|
||||
|
||||
This library is a modified version of the noise library found in
|
||||
Open Shading Language:
|
||||
github.com/imageworks/OpenShadingLanguage/blob/master/src/include/OSL/oslnoise.h
|
||||
|
||||
It contains the subset of noise types needed to implement the MaterialX
|
||||
standard library. The modifications are mainly conversions from C++ to MDL.
|
||||
Produced results should be identical to the OSL noise functions.
|
||||
|
||||
Original copyright notice:
|
||||
------------------------------------------------------------------------
|
||||
Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
|
||||
All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Sony Pictures Imageworks nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
------------------------------------------------------------------------
|
||||
********************************************************************************/
|
||||
|
||||
mdl 1.6;
|
||||
|
||||
import ::anno::*;
|
||||
import ::math::*;
|
||||
import ::state::*;
|
||||
|
||||
import .::core::*;
|
||||
import .::swizzle::*;
|
||||
|
||||
float mx_bilerp_float(float v0, float v1, float v2, float v3, float s, float t)
|
||||
{
|
||||
float s1 = 1.0 - s;
|
||||
return (1.0 - t) * (v0*s1 + v1*s) + t * (v2*s1 + v3*s);
|
||||
}
|
||||
float3 mx_bilerp_float3(float3 v0, float3 v1, float3 v2, float3 v3, float s, float t)
|
||||
{
|
||||
float s1 = 1.0 - s;
|
||||
return (1.0 - t) * (v0*s1 + v1*s) + t * (v2*s1 + v3*s);
|
||||
}
|
||||
float mx_trilerp_float(float v0, float v1, float v2, float v3, float v4, float v5, float v6, float v7, float s, float t, float r)
|
||||
{
|
||||
float s1 = 1.0 - s;
|
||||
float t1 = 1.0 - t;
|
||||
float r1 = 1.0 - r;
|
||||
return (r1*(t1*(v0*s1 + v1*s) + t*(v2*s1 + v3*s)) +
|
||||
r*(t1*(v4*s1 + v5*s) + t*(v6*s1 + v7*s)));
|
||||
}
|
||||
float3 mx_trilerp_float3(float3 v0, float3 v1, float3 v2, float3 v3, float3 v4, float3 v5, float3 v6, float3 v7, float s, float t, float r)
|
||||
{
|
||||
float s1 = 1.0 - s;
|
||||
float t1 = 1.0 - t;
|
||||
float r1 = 1.0 - r;
|
||||
return (r1*(t1*(v0*s1 + v1*s) + t*(v2*s1 + v3*s)) +
|
||||
r*(t1*(v4*s1 + v5*s) + t*(v6*s1 + v7*s)));
|
||||
}
|
||||
|
||||
// 2 and 3 dimensional gradient functions - perform a dot product against a
|
||||
// randomly chosen vector. Note that the gradient vector is not normalized, but
|
||||
// this only affects the overal "scale" of the result, so we simply account for
|
||||
// the scale by multiplying in the corresponding "perlin" function.
|
||||
float mx_gradient_float(int mxp_hash, float mxp_x, float mxp_y)
|
||||
{
|
||||
// 8 possible directions (+-1,+-2) and (+-2,+-1)
|
||||
int h = mxp_hash & 7;
|
||||
float u = h<4 ? mxp_x : mxp_y;
|
||||
float v = 2.0 * (h<4 ? mxp_y : mxp_x);
|
||||
// compute the dot product with (x,y).
|
||||
return (((h&1)!=0) ? -u : u) + (((h&2) != 0) ? -v : v);
|
||||
}
|
||||
float mx_gradient_float(int mxp_hash, float mxp_x, float mxp_y, float mxp_z)
|
||||
{
|
||||
// use vectors pointing to the edges of the cube
|
||||
int h = mxp_hash & 15;
|
||||
float u = h<8 ? mxp_x : mxp_y;
|
||||
float v = h<4 ? mxp_y : ((h==12)||(h==14)) ? mxp_x : mxp_z;
|
||||
return (((h&1)!=0)?-u:u) + (((h&2)!=0)?-v:v);
|
||||
}
|
||||
float3 mx_gradient_float3(int3 mxp_hash, float mxp_x, float mxp_y)
|
||||
{
|
||||
return float3(mx_gradient_float(mxp_hash.x, mxp_x, mxp_y),
|
||||
mx_gradient_float(mxp_hash.y, mxp_x, mxp_y),
|
||||
mx_gradient_float(mxp_hash.z, mxp_x, mxp_y));
|
||||
}
|
||||
float3 mx_gradient_float3(int3 mxp_hash, float mxp_x, float mxp_y, float mxp_z)
|
||||
{
|
||||
return float3(mx_gradient_float(mxp_hash.x, mxp_x, mxp_y, mxp_z),
|
||||
mx_gradient_float(mxp_hash.y, mxp_x, mxp_y, mxp_z),
|
||||
mx_gradient_float(mxp_hash.z, mxp_x, mxp_y, mxp_z));
|
||||
}
|
||||
// Scaling factors to normalize the result of gradients above.
|
||||
// These factors were experimentally calculated to be:
|
||||
// 2D: 0.6616
|
||||
// 3D: 0.9820
|
||||
//JAN: why do those differ from osl sourcecode?
|
||||
float mx_gradient_scale2d_float(float mxp_v) { return 0.6616 * mxp_v; }
|
||||
float mx_gradient_scale3d_float(float mxp_v) { return 0.9820 * mxp_v; }
|
||||
float3 mx_gradient_scale2d_float3(float3 mxp_v) { return 0.6616 * mxp_v; }
|
||||
float3 mx_gradient_scale3d_float3(float3 mxp_v) { return 0.9820 * mxp_v; }
|
||||
|
||||
/// Bitwise circular rotation left by k bits (for 32 bit unsigned integers)
|
||||
int mx_rotl32(int mxp_x, int mxp_k)
|
||||
{
|
||||
return (mxp_x<<mxp_k) | (mxp_x>>>(32-mxp_k)); //note the unsigned right shift
|
||||
}
|
||||
|
||||
int3 mx_bjmix(int a, int b, int c)
|
||||
{
|
||||
a -= c; a ^= mx_rotl32(c, 4); c += b;
|
||||
b -= a; b ^= mx_rotl32(a, 6); a += c;
|
||||
c -= b; c ^= mx_rotl32(b, 8); b += a;
|
||||
a -= c; a ^= mx_rotl32(c,16); c += b;
|
||||
b -= a; b ^= mx_rotl32(a,19); a += c;
|
||||
c -= b; c ^= mx_rotl32(b, 4); b += a;
|
||||
return int3(a, b, c);
|
||||
}
|
||||
|
||||
// Mix up and combine the bits of a, b, and c (doesn't change them, but
|
||||
// returns a hash of those three original values).
|
||||
int mx_bjfinal(int mxp_a, int mxp_b, int mxp_c)
|
||||
{
|
||||
mxp_c ^= mxp_b; mxp_c -= mx_rotl32(mxp_b,14);
|
||||
mxp_a ^= mxp_c; mxp_a -= mx_rotl32(mxp_c,11);
|
||||
mxp_b ^= mxp_a; mxp_b -= mx_rotl32(mxp_a,25);
|
||||
mxp_c ^= mxp_b; mxp_c -= mx_rotl32(mxp_b,16);
|
||||
mxp_a ^= mxp_c; mxp_a -= mx_rotl32(mxp_c,4);
|
||||
mxp_b ^= mxp_a; mxp_b -= mx_rotl32(mxp_a,14);
|
||||
mxp_c ^= mxp_b; mxp_c -= mx_rotl32(mxp_b,24);
|
||||
return mxp_c;
|
||||
}
|
||||
|
||||
// Convert a 32 bit integer into a floating point number in [0,1]
|
||||
float mx_bits_to_01(int mxp_bits)
|
||||
{
|
||||
return mxp_bits >=0 ? float(mxp_bits) / 4294967295.:
|
||||
float(mxp_bits>>>1)/ 2147483647.;
|
||||
}
|
||||
|
||||
float mx_fade(float mxp_t)
|
||||
{
|
||||
return mxp_t * mxp_t * mxp_t * (mxp_t * (mxp_t * 6.0 - 15.0) + 10.0);
|
||||
}
|
||||
|
||||
int mx_hash_int(int mxp_x)
|
||||
{
|
||||
int len = 1;
|
||||
int seed = int(0xdeadbeef) + (len << 2) + 13;
|
||||
return mx_bjfinal(seed + mxp_x, seed, seed);
|
||||
}
|
||||
|
||||
int mx_hash_int(int mxp_x, int mxp_y)
|
||||
{
|
||||
int len = 2;
|
||||
int a, b, c;
|
||||
a = b = c = int(0xdeadbeef) + (len << 2) + 13;
|
||||
a += mxp_x;
|
||||
b += mxp_y;
|
||||
return mx_bjfinal(a, b, c);
|
||||
}
|
||||
|
||||
int mx_hash_int(int mxp_x, int mxp_y, int mxp_z)
|
||||
{
|
||||
int len = 3;
|
||||
int a, b, c;
|
||||
a = b = c = int(0xdeadbeef) + (len << 2) + 13;
|
||||
a += mxp_x;
|
||||
b += mxp_y;
|
||||
c += mxp_z;
|
||||
return mx_bjfinal(a, b, c);
|
||||
}
|
||||
|
||||
int mx_hash_int(int x, int y, int z, int xx)
|
||||
{
|
||||
int len = 4;
|
||||
int a, b, c;
|
||||
a = b = c = int(0xdeadbeef) + (len << 2) + 13;
|
||||
a += x;
|
||||
b += y;
|
||||
c += z;
|
||||
int3 abc = mx_bjmix(a, b, c);
|
||||
a = abc.x;
|
||||
b = abc.y;
|
||||
c = abc.z;
|
||||
a += xx;
|
||||
return mx_bjfinal(a, b, c);
|
||||
}
|
||||
|
||||
int mx_hash_int(int x, int y, int z, int xx, int yy)
|
||||
{
|
||||
int len = 5;
|
||||
int a, b, c;
|
||||
a = b = c = int(0xdeadbeef) + (len << 2) + 13;
|
||||
a += x;
|
||||
b += y;
|
||||
c += z;
|
||||
int3 abc = mx_bjmix(a, b, c);
|
||||
a = abc.x;
|
||||
b = abc.y;
|
||||
c = abc.z;
|
||||
a += xx;
|
||||
b += yy;
|
||||
return mx_bjfinal(a, b, c);
|
||||
}
|
||||
|
||||
int3 mx_hash_int3(int mxp_x, int mxp_y)
|
||||
{
|
||||
int h = mx_hash_int(mxp_x, mxp_y);
|
||||
// we only need the low-order bits to be random, so split out
|
||||
// the 32 bit result into 3 parts for each channel
|
||||
int3 result;
|
||||
result.x = (h ) & 0xFF;
|
||||
result.y = (h >>> 8 ) & 0xFF;
|
||||
result.z = (h >>> 16) & 0xFF;
|
||||
return result;
|
||||
}
|
||||
|
||||
int3 mx_hash_int3(int mxp_x, int mxp_y, int mxp_z)
|
||||
{
|
||||
int h = mx_hash_int(mxp_x, mxp_y, mxp_z);
|
||||
// we only need the low-order bits to be random, so split out
|
||||
// the 32 bit result into 3 parts for each channel
|
||||
int3 result;
|
||||
result.x = (h ) & 0xFF;
|
||||
result.y = (h >>> 8 ) & 0xFF;
|
||||
result.z = (h >>> 16) & 0xFF;
|
||||
return result;
|
||||
}
|
||||
|
||||
export float mx_perlin_noise_float(
|
||||
float2 mxp_p = swizzle::xy( ::state::texture_coordinate(0)))
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
float ix=math::floor(mxp_p.x);
|
||||
float iy=math::floor(mxp_p.y);
|
||||
int X = int(ix);
|
||||
int Y = int(iy);
|
||||
float fx = mxp_p.x-ix;
|
||||
float fy = mxp_p.y-iy;
|
||||
float u = mx_fade(fx);
|
||||
float v = mx_fade(fy);
|
||||
float result = mx_bilerp_float(
|
||||
mx_gradient_float(mx_hash_int(X , Y ), fx , fy ),
|
||||
mx_gradient_float(mx_hash_int(X+1, Y ), fx-1.0, fy ),
|
||||
mx_gradient_float(mx_hash_int(X , Y+1), fx , fy-1.0),
|
||||
mx_gradient_float(mx_hash_int(X+1, Y+1), fx-1.0, fy-1.0),
|
||||
u, v);
|
||||
return mx_gradient_scale2d_float(result);
|
||||
}
|
||||
|
||||
export float3 mx_perlin_noise_float3(
|
||||
float2 mxp_p = swizzle::xy( ::state::texture_coordinate(0)))
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
float ix=math::floor(mxp_p.x);
|
||||
float iy=math::floor(mxp_p.y);
|
||||
int X = int(ix);
|
||||
int Y = int(iy);
|
||||
float fx = mxp_p.x-ix;
|
||||
float fy = mxp_p.y-iy;
|
||||
float u = mx_fade(fx);
|
||||
float v = mx_fade(fy);
|
||||
float3 result = mx_bilerp_float3(
|
||||
mx_gradient_float3(mx_hash_int3(X , Y ), fx , fy ),
|
||||
mx_gradient_float3(mx_hash_int3(X+1, Y ), fx-1.0, fy ),
|
||||
mx_gradient_float3(mx_hash_int3(X , Y+1), fx , fy-1.0),
|
||||
mx_gradient_float3(mx_hash_int3(X+1, Y+1), fx-1.0, fy-1.0),
|
||||
u, v);
|
||||
return mx_gradient_scale2d_float3(result);
|
||||
}
|
||||
|
||||
export float mx_perlin_noise_float(
|
||||
float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()))
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
float ix=math::floor(mxp_p.x);
|
||||
float iy=math::floor(mxp_p.y);
|
||||
float iz=math::floor(mxp_p.z);
|
||||
int X = int(ix);
|
||||
int Y = int(iy);
|
||||
int Z = int(iz);
|
||||
float fx = mxp_p.x-ix;
|
||||
float fy = mxp_p.y-iy;
|
||||
float fz = mxp_p.z-iz;
|
||||
float u = mx_fade(fx);
|
||||
float v = mx_fade(fy);
|
||||
float w = mx_fade(fz);
|
||||
float result = mx_trilerp_float(
|
||||
mx_gradient_float(mx_hash_int(X , Y , Z ), fx , fy , fz ),
|
||||
mx_gradient_float(mx_hash_int(X+1, Y , Z ), fx-1.0, fy , fz ),
|
||||
mx_gradient_float(mx_hash_int(X , Y+1, Z ), fx , fy-1.0, fz ),
|
||||
mx_gradient_float(mx_hash_int(X+1, Y+1, Z ), fx-1.0, fy-1.0, fz ),
|
||||
mx_gradient_float(mx_hash_int(X , Y , Z+1), fx , fy , fz-1.0),
|
||||
mx_gradient_float(mx_hash_int(X+1, Y , Z+1), fx-1.0, fy , fz-1.0),
|
||||
mx_gradient_float(mx_hash_int(X , Y+1, Z+1), fx , fy-1.0, fz-1.0),
|
||||
mx_gradient_float(mx_hash_int(X+1, Y+1, Z+1), fx-1.0, fy-1.0, fz-1.0),
|
||||
u, v, w);
|
||||
return mx_gradient_scale3d_float(result);
|
||||
}
|
||||
|
||||
export float3 mx_perlin_noise_float3(
|
||||
float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()))
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
float ix=math::floor(mxp_p.x);
|
||||
float iy=math::floor(mxp_p.y);
|
||||
float iz=math::floor(mxp_p.z);
|
||||
int X = int(ix);
|
||||
int Y = int(iy);
|
||||
int Z = int(iz);
|
||||
float fx = mxp_p.x-ix;
|
||||
float fy = mxp_p.y-iy;
|
||||
float fz = mxp_p.z-iz;
|
||||
float u = mx_fade(fx);
|
||||
float v = mx_fade(fy);
|
||||
float w = mx_fade(fz);
|
||||
float3 result = mx_trilerp_float3(
|
||||
mx_gradient_float3(mx_hash_int3(X , Y , Z ), fx , fy , fz ),
|
||||
mx_gradient_float3(mx_hash_int3(X+1, Y , Z ), fx-1.0, fy , fz ),
|
||||
mx_gradient_float3(mx_hash_int3(X , Y+1, Z ), fx , fy-1.0, fz ),
|
||||
mx_gradient_float3(mx_hash_int3(X+1, Y+1, Z ), fx-1.0, fy-1.0, fz ),
|
||||
mx_gradient_float3(mx_hash_int3(X , Y , Z+1), fx , fy , fz-1.0),
|
||||
mx_gradient_float3(mx_hash_int3(X+1, Y , Z+1), fx-1.0, fy , fz-1.0),
|
||||
mx_gradient_float3(mx_hash_int3(X , Y+1, Z+1), fx , fy-1.0, fz-1.0),
|
||||
mx_gradient_float3(mx_hash_int3(X+1, Y+1, Z+1), fx-1.0, fy-1.0, fz-1.0),
|
||||
u, v, w);
|
||||
return mx_gradient_scale3d_float3(result);
|
||||
}
|
||||
|
||||
export float mx_cell_noise_float(float mxp_p)
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
int ix = math::floor(mxp_p);
|
||||
return mx_bits_to_01(mx_hash_int(ix));
|
||||
}
|
||||
|
||||
export float mx_cell_noise_float(
|
||||
float2 mxp_p = swizzle::xy( ::state::texture_coordinate(0)))
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
int ix = math::floor(mxp_p.x);
|
||||
int iy = math::floor(mxp_p.y);
|
||||
return mx_bits_to_01(mx_hash_int(ix, iy));
|
||||
}
|
||||
|
||||
export float mx_cell_noise_float(
|
||||
float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()))
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
int ix = math::floor(mxp_p.x);
|
||||
int iy = math::floor(mxp_p.y);
|
||||
int iz = math::floor(mxp_p.z);
|
||||
return mx_bits_to_01(mx_hash_int(ix, iy, iz));
|
||||
}
|
||||
|
||||
export float mx_cell_noise_float(float4 mxp_p)
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
int ix = math::floor(mxp_p.x);
|
||||
int iy = math::floor(mxp_p.y);
|
||||
int iz = math::floor(mxp_p.z);
|
||||
int iw = math::floor(mxp_p.w);
|
||||
return mx_bits_to_01(mx_hash_int(ix, iy, iz, iw));
|
||||
}
|
||||
|
||||
export float3 mx_cell_noise_float3(float mxp_p)
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
int ix = math::floor(mxp_p);
|
||||
return float3(
|
||||
mx_bits_to_01(mx_hash_int(ix, 0)),
|
||||
mx_bits_to_01(mx_hash_int(ix, 1)),
|
||||
mx_bits_to_01(mx_hash_int(ix, 2))
|
||||
);
|
||||
}
|
||||
|
||||
export float3 mx_cell_noise_float3(
|
||||
float2 mxp_p = swizzle::xy( ::state::texture_coordinate(0)))
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
int ix = math::floor(mxp_p.x);
|
||||
int iy = math::floor(mxp_p.y);
|
||||
return float3(
|
||||
mx_bits_to_01(mx_hash_int(ix, iy, 0)),
|
||||
mx_bits_to_01(mx_hash_int(ix, iy, 1)),
|
||||
mx_bits_to_01(mx_hash_int(ix, iy, 2))
|
||||
);
|
||||
}
|
||||
|
||||
export float3 mx_cell_noise_float3(
|
||||
float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()))
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
int ix = math::floor(mxp_p.x);
|
||||
int iy = math::floor(mxp_p.y);
|
||||
int iz = math::floor(mxp_p.z);
|
||||
return float3(
|
||||
mx_bits_to_01(mx_hash_int(ix, iy, iz, 0)),
|
||||
mx_bits_to_01(mx_hash_int(ix, iy, iz, 1)),
|
||||
mx_bits_to_01(mx_hash_int(ix, iy, iz, 2))
|
||||
);
|
||||
}
|
||||
|
||||
export float3 mx_cell_noise_float3(float4 mxp_p)
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
int ix = math::floor(mxp_p.x);
|
||||
int iy = math::floor(mxp_p.y);
|
||||
int iz = math::floor(mxp_p.z);
|
||||
int iw = math::floor(mxp_p.w);
|
||||
return float3(
|
||||
mx_bits_to_01(mx_hash_int(ix, iy, iz, iw, 0)),
|
||||
mx_bits_to_01(mx_hash_int(ix, iy, iz, iw, 1)),
|
||||
mx_bits_to_01(mx_hash_int(ix, iy, iz, iw, 2))
|
||||
);
|
||||
}
|
||||
|
||||
export float mx_fractal_noise_float(
|
||||
float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()),
|
||||
int mxp_octaves = 3,
|
||||
float mxp_lacunarity = 2.0,
|
||||
float mxp_diminish= 0.5)
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
float result = 0.0;
|
||||
float amplitude = 1.0;
|
||||
for (int i = 0; i < mxp_octaves; ++i)
|
||||
{
|
||||
result += amplitude * mx_perlin_noise_float(mxp_p);
|
||||
amplitude *= mxp_diminish;
|
||||
mxp_p *= mxp_lacunarity;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export float3 mx_fractal_noise_float3(
|
||||
float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()),
|
||||
int mxp_octaves = 3,
|
||||
float mxp_lacunarity = 2.0,
|
||||
float mxp_diminish= 0.5)
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
float3 result = float3(0.0);
|
||||
float amplitude = 1.0;
|
||||
for (int i = 0; i < mxp_octaves; ++i)
|
||||
{
|
||||
result += amplitude * mx_perlin_noise_float3(mxp_p);
|
||||
amplitude *= mxp_diminish;
|
||||
mxp_p *= mxp_lacunarity;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export float2 mx_fractal_noise_float2(
|
||||
float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()),
|
||||
int mxp_octaves = 3,
|
||||
float mxp_lacunarity = 2.0,
|
||||
float mxp_diminish= 0.5)
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
return float2(mx_fractal_noise_float(mxp_p, mxp_octaves, mxp_lacunarity, mxp_diminish),
|
||||
mx_fractal_noise_float(mxp_p+float3(19, 193, 17), mxp_octaves, mxp_lacunarity, mxp_diminish));
|
||||
}
|
||||
|
||||
export float4 mx_fractal_noise_float4(
|
||||
float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()),
|
||||
int mxp_octaves = 3,
|
||||
float mxp_lacunarity = 2.0,
|
||||
float mxp_diminish= 0.5)
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
|
||||
float3 c = mx_fractal_noise_float3(mxp_p, mxp_octaves, mxp_lacunarity, mxp_diminish);
|
||||
float a = mx_fractal_noise_float(mxp_p+float3(19, 193, 17), mxp_octaves, mxp_lacunarity, mxp_diminish);
|
||||
return float4(c.x, c.y, c.z, a);
|
||||
}
|
||||
|
||||
float mx_worley_distance2(float2 p, int x, int y, int xoff, int yoff, float jitter, int metric)
|
||||
{
|
||||
float3 tmp = mx_cell_noise_float3(float2(x+xoff, y+yoff));
|
||||
float2 off = float2(tmp.x, tmp.y);
|
||||
|
||||
off -= 0.5f;
|
||||
off *= jitter;
|
||||
off += 0.5f;
|
||||
|
||||
float2 cellpos = float2(float(x), float(y)) + off;
|
||||
float2 diff = cellpos - p;
|
||||
if (metric == 2)
|
||||
return math::abs(diff.x) + math::abs(diff.y); // Manhattan distance
|
||||
if (metric == 3)
|
||||
return math::max(math::abs(diff.x), math::abs(diff.y)); // Chebyshev distance
|
||||
// Either Euclidian or Distance^2
|
||||
return math::dot(diff, diff);
|
||||
}
|
||||
|
||||
float mx_worley_distance3(float3 p, int x, int y, int z, int xoff, int yoff, int zoff, float jitter, int metric)
|
||||
{
|
||||
float3 off = mx_cell_noise_float3(float3(x+xoff, y+yoff, z+zoff));
|
||||
|
||||
off -= 0.5f;
|
||||
off *= jitter;
|
||||
off += 0.5f;
|
||||
|
||||
float3 cellpos = float3(float(x), float(y), float(z)) + off;
|
||||
float3 diff = cellpos - p;
|
||||
if (metric == 2)
|
||||
return math::abs(diff.x) + math::abs(diff.y) + math::abs(diff.z); // Manhattan distance
|
||||
if (metric == 3)
|
||||
return math::max(math::max(math::abs(diff.x), math::abs(diff.y)), math::abs(diff.z)); // Chebyshev distance
|
||||
// Either Euclidian or Distance^2
|
||||
return math::dot(diff, diff);
|
||||
}
|
||||
|
||||
export float mx_worley_noise_float(float2 p, float jitter, int metric)
|
||||
{
|
||||
float ix = math::floor(p.x);
|
||||
float iy = math::floor(p.y);
|
||||
int X = int(ix);
|
||||
int Y = int(iy);
|
||||
float2 localpos = float2(p.x-ix, p.y-iy);
|
||||
|
||||
float sqdist = 1e6f; // Some big number for jitter > 1 (not all GPUs may be IEEE)
|
||||
for (int x = -1; x <= 1; ++x)
|
||||
{
|
||||
for (int y = -1; y <= 1; ++y)
|
||||
{
|
||||
float dist = mx_worley_distance2(localpos, x, y, X, Y, jitter, metric);
|
||||
sqdist = math::min(sqdist, dist);
|
||||
}
|
||||
}
|
||||
if (metric == 0)
|
||||
sqdist = math::sqrt(sqdist);
|
||||
return sqdist;
|
||||
}
|
||||
|
||||
export float2 mx_worley_noise_float2(float2 p, float jitter, int metric)
|
||||
{
|
||||
float ix = math::floor(p.x);
|
||||
float iy = math::floor(p.y);
|
||||
int X = int(ix);
|
||||
int Y = int(iy);
|
||||
float2 localpos = float2(p.x-ix, p.y-iy);
|
||||
|
||||
float2 sqdist = float2(1e6f, 1e6f);
|
||||
for (int x = -1; x <= 1; ++x)
|
||||
{
|
||||
for (int y = -1; y <= 1; ++y)
|
||||
{
|
||||
float dist = mx_worley_distance2(localpos, x, y, X, Y, jitter, metric);
|
||||
if (dist < sqdist.x)
|
||||
{
|
||||
sqdist.y = sqdist.x;
|
||||
sqdist.x = dist;
|
||||
}
|
||||
else if (dist < sqdist.y)
|
||||
{
|
||||
sqdist.y = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (metric == 0)
|
||||
sqdist = math::sqrt(sqdist);
|
||||
return sqdist;
|
||||
}
|
||||
|
||||
export float3 mx_worley_noise_float3(float2 p, float jitter, int metric)
|
||||
{
|
||||
float ix = math::floor(p.x);
|
||||
float iy = math::floor(p.y);
|
||||
int X = int(ix);
|
||||
int Y = int(iy);
|
||||
float2 localpos = float2(p.x-ix, p.y-iy);
|
||||
|
||||
float3 sqdist = float3(1e6f, 1e6f, 1e6f);
|
||||
for (int x = -1; x <= 1; ++x)
|
||||
{
|
||||
for (int y = -1; y <= 1; ++y)
|
||||
{
|
||||
float dist = mx_worley_distance2(localpos, x, y, X, Y, jitter, metric);
|
||||
if (dist < sqdist.x)
|
||||
{
|
||||
sqdist.z = sqdist.y;
|
||||
sqdist.y = sqdist.x;
|
||||
sqdist.x = dist;
|
||||
}
|
||||
else if (dist < sqdist.y)
|
||||
{
|
||||
sqdist.z = sqdist.y;
|
||||
sqdist.y = dist;
|
||||
}
|
||||
else if (dist < sqdist.z)
|
||||
{
|
||||
sqdist.z = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (metric == 0)
|
||||
sqdist = math::sqrt(sqdist);
|
||||
return sqdist;
|
||||
}
|
||||
|
||||
export float mx_worley_noise_float(float3 p, float jitter, int metric)
|
||||
{
|
||||
float ix = math::floor(p.x);
|
||||
float iy = math::floor(p.y);
|
||||
float iz = math::floor(p.z);
|
||||
int X = int(ix);
|
||||
int Y = int(iy);
|
||||
int Z = int(iz);
|
||||
float3 localpos = float3(p.x-ix, p.y-iy, p.z-iz);
|
||||
|
||||
float sqdist = 1e6f;
|
||||
for (int x = -1; x <= 1; ++x)
|
||||
{
|
||||
for (int y = -1; y <= 1; ++y)
|
||||
{
|
||||
for (int z = -1; z <= 1; ++z)
|
||||
{
|
||||
float dist = mx_worley_distance3(localpos, x, y, z, X, Y, Z, jitter, metric);
|
||||
sqdist = math::min(sqdist, dist);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (metric == 0)
|
||||
sqdist = math::sqrt(sqdist);
|
||||
return sqdist;
|
||||
}
|
||||
|
||||
export float2 mx_worley_noise_float2(float3 p, float jitter, int metric)
|
||||
{
|
||||
float ix = math::floor(p.x);
|
||||
float iy = math::floor(p.y);
|
||||
float iz = math::floor(p.z);
|
||||
int X = int(ix);
|
||||
int Y = int(iy);
|
||||
int Z = int(iz);
|
||||
float3 localpos = float3(p.x-ix, p.y-iy, p.z-iz);
|
||||
|
||||
float2 sqdist = float2(1e6f, 1e6f);
|
||||
for (int x = -1; x <= 1; ++x)
|
||||
{
|
||||
for (int y = -1; y <= 1; ++y)
|
||||
{
|
||||
for (int z = -1; z <= 1; ++z)
|
||||
{
|
||||
float dist = mx_worley_distance3(localpos, x, y, z, X, Y, Z, jitter, metric);
|
||||
if (dist < sqdist.x)
|
||||
{
|
||||
sqdist.y = sqdist.x;
|
||||
sqdist.x = dist;
|
||||
}
|
||||
else if (dist < sqdist.y)
|
||||
{
|
||||
sqdist.y = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (metric == 0)
|
||||
sqdist = math::sqrt(sqdist);
|
||||
return sqdist;
|
||||
}
|
||||
|
||||
export float3 mx_worley_noise_float3(float3 p, float jitter, int metric)
|
||||
{
|
||||
float ix = math::floor(p.x);
|
||||
float iy = math::floor(p.y);
|
||||
float iz = math::floor(p.z);
|
||||
int X = int(ix);
|
||||
int Y = int(iy);
|
||||
int Z = int(iz);
|
||||
float3 localpos = float3(p.x-ix, p.y-iy, p.z-iz);
|
||||
|
||||
float3 sqdist = float3(1e6f, 1e6f, 1e6f);
|
||||
for (int x = -1; x <= 1; ++x)
|
||||
{
|
||||
for (int y = -1; y <= 1; ++y)
|
||||
{
|
||||
for (int z = -1; z <= 1; ++z)
|
||||
{
|
||||
float dist = mx_worley_distance3(localpos, x, y, z, X, Y, Z, jitter, metric);
|
||||
if (dist < sqdist.x)
|
||||
{
|
||||
sqdist.z = sqdist.y;
|
||||
sqdist.y = sqdist.x;
|
||||
sqdist.x = dist;
|
||||
}
|
||||
else if (dist < sqdist.y)
|
||||
{
|
||||
sqdist.z = sqdist.y;
|
||||
sqdist.y = dist;
|
||||
}
|
||||
else if (dist < sqdist.z)
|
||||
{
|
||||
sqdist.z = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (metric == 0)
|
||||
sqdist = math::sqrt(sqdist);
|
||||
return sqdist;
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// MDL implementation of all types and nodes of
|
||||
// MaterialX Physically-Based Shading Nodes
|
||||
// Document v1.37 REV2, July 16, 2019 (Revised October 17, 2019)
|
||||
// see www.materialx.org
|
||||
// in
|
||||
// NVIDIA Material Definition Language 1.8
|
||||
// Language Specification
|
||||
// Document version 1.8.2, May 24, 2023
|
||||
// www.nvidia.com/mdl
|
||||
|
||||
mdl 1.8;
|
||||
|
||||
// forward the latest version
|
||||
export using .::pbrlib_1_8 import *;
|
||||
Vendored
+1009
File diff suppressed because it is too large
Load Diff
Vendored
+259
@@ -0,0 +1,259 @@
|
||||
/*
|
||||
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// MDL implementation of all types and nodes of
|
||||
// MaterialX Physically-Based Shading Nodes
|
||||
// Document v1.37 REV2, July 16, 2019 (Revised October 17, 2019)
|
||||
// see www.materialx.org
|
||||
// in
|
||||
// NVIDIA Material Definition Language 1.7
|
||||
// Language Specification
|
||||
// Document version 1.7.2, January 17, 2022
|
||||
// www.nvidia.com/mdl
|
||||
|
||||
mdl 1.7;
|
||||
|
||||
// Changes since MDL 1.6
|
||||
// - Support for unbounded_mix to implement add_bsdf, add_edf, and add_vdf
|
||||
// - Support for df::sheen_bsdf with a custom base BSDF
|
||||
// - Support for df::directional_factor on EDFs to implement generalized_schlick_edf
|
||||
// - Support for emission on VDFs
|
||||
|
||||
import ::anno::*;
|
||||
import ::df::*;
|
||||
import ::math::*;
|
||||
import ::state::*;
|
||||
|
||||
// forward all unchanged definitions from the previous version
|
||||
export using .::pbrlib_1_6 import mx_scatter_mode;
|
||||
export using .::pbrlib_1_6 import mx_map_scatter_mode;
|
||||
export using .::pbrlib_1_6 import mx_oren_nayar_diffuse_bsdf;
|
||||
export using .::pbrlib_1_6 import mx_burley_diffuse_bsdf;
|
||||
export using .::pbrlib_1_6 import mx_translucent_bsdf;
|
||||
export using .::pbrlib_1_6 import mx_dielectric_bsdf;
|
||||
export using .::pbrlib_1_6 import mx_conductor_bsdf;
|
||||
export using .::pbrlib_1_6 import mx_generalized_schlick_bsdf;
|
||||
export using .::pbrlib_1_6 import mx_subsurface_bsdf;
|
||||
export using .::pbrlib_1_6 import mx_thin_film_bsdf;
|
||||
export using .::pbrlib_1_6 import mx_uniform_edf;
|
||||
export using .::pbrlib_1_6 import mx_conical_edf;
|
||||
export using .::pbrlib_1_6 import mx_measured_edf;
|
||||
export using .::pbrlib_1_6 import mx_absorption_vdf;
|
||||
export using .::pbrlib_1_6 import mx_anisotropic_vdf;
|
||||
export using .::pbrlib_1_6 import mx_surface;
|
||||
export using .::pbrlib_1_6 import mx_thin_surface;
|
||||
export using .::pbrlib_1_6 import mx_light;
|
||||
export using .::pbrlib_1_6 import mx_displacement_float;
|
||||
export using .::pbrlib_1_6 import mx_displacement_vector3;
|
||||
export using .::pbrlib_1_6 import volume_mix_return;
|
||||
export using .::pbrlib_1_6 import volume_mix;
|
||||
export using .::pbrlib_1_6 import mx_mix_bsdf;
|
||||
export using .::pbrlib_1_6 import mx_mix_vdf;
|
||||
export using .::pbrlib_1_6 import mx_multiply_bsdf_color3;
|
||||
export using .::pbrlib_1_6 import mx_multiply_bsdf_float;
|
||||
export using .::pbrlib_1_6 import mx_multiply_edf_color3;
|
||||
export using .::pbrlib_1_6 import mx_multiply_edf_float;
|
||||
export using .::pbrlib_1_6 import mx_multiply_vdf_color3;
|
||||
export using .::pbrlib_1_6 import mx_multiply_vdf_float;
|
||||
export using .::pbrlib_1_6 import mx_roughness_anisotropy;
|
||||
export using .::pbrlib_1_6 import mx_roughness_dual;
|
||||
export using .::pbrlib_1_6 import mx_blackbody;
|
||||
export using .::pbrlib_1_6 import mx_artistic_ior__result ;
|
||||
export using .::pbrlib_1_6 import mx_artistic_ior;
|
||||
|
||||
|
||||
|
||||
// To match with OSL, the sheen weight is scaled with average color as approximation of albedo.
|
||||
// OSL uses the layer operator which mixes based on albedo.
|
||||
export material mx_sheen_bsdf(
|
||||
float mxp_weight = 1.0,
|
||||
color mxp_color = color(1.0),
|
||||
float mxp_roughness = 0.2,
|
||||
float3 mxp_normal = state::normal(),
|
||||
material mxp_base = material(
|
||||
surface: material_surface(
|
||||
scattering: df::diffuse_reflection_bsdf(
|
||||
))) [[ anno::usage( "materialx:bsdf") ]]
|
||||
) [[
|
||||
anno::usage( "materialx:bsdf")
|
||||
]]
|
||||
= material(
|
||||
surface: material_surface(
|
||||
// using the mix seems to fit OSL best, at least in the test cases
|
||||
scattering: df::weighted_layer(
|
||||
weight: math::average(mxp_color) * mxp_weight,
|
||||
layer: df::sheen_bsdf(
|
||||
roughness: mxp_roughness,
|
||||
tint: mxp_color,
|
||||
multiscatter_tint: color(1.0),
|
||||
multiscatter: mxp_base.surface.scattering
|
||||
),
|
||||
base: mxp_base.surface.scattering,
|
||||
normal: mxp_normal)),
|
||||
// we need to carry volume properties along for SSS
|
||||
ior: mxp_base.ior,
|
||||
volume: mxp_base.volume
|
||||
);
|
||||
|
||||
|
||||
// NOTE: Adding two BSDFs is not supported in MDL, the generator would best
|
||||
// analyze the context for mixing weights and replace the add with a mix.
|
||||
// The provided implementation just mixes the BSDFs with equal weight.
|
||||
export material mx_add_bsdf(
|
||||
material mxp_in1 = material() [[ anno::usage( "materialx:bsdf") ]],
|
||||
material mxp_in2 = material() [[ anno::usage( "materialx:bsdf") ]]
|
||||
) [[
|
||||
anno::usage( "materialx:bsdf")
|
||||
]]
|
||||
= let {
|
||||
volume_mix_return v = volume_mix(
|
||||
mxp_in1.volume.scattering_coefficient, 1.0f,
|
||||
mxp_in2.volume.scattering_coefficient, 1.0f);
|
||||
} in material(
|
||||
surface: material_surface(
|
||||
scattering: df::unbounded_mix(
|
||||
df::bsdf_component[](
|
||||
df::bsdf_component( 1.0, mxp_in1.surface.scattering),
|
||||
df::bsdf_component( 1.0, mxp_in2.surface.scattering)
|
||||
)
|
||||
)
|
||||
),
|
||||
// we need to carry volume properties along for SSS
|
||||
volume: material_volume(
|
||||
scattering: df::unbounded_mix(
|
||||
df::vdf_component[](
|
||||
df::vdf_component( v.mix_weight1, mxp_in1.volume.scattering),
|
||||
df::vdf_component( 1.0 - v.mix_weight1, mxp_in2.volume.scattering))
|
||||
),
|
||||
absorption_coefficient: mxp_in1.volume.absorption_coefficient +
|
||||
mxp_in2.volume.absorption_coefficient,
|
||||
scattering_coefficient: v.scattering_coefficient
|
||||
)
|
||||
);
|
||||
|
||||
// NOTE: Adding two EDFs is not supported in MDL, the generator would best
|
||||
// analyze the context for mixing weights and replace the add with a mix.
|
||||
// The provided implementation just mixes the EDFs with equal weight
|
||||
// and adds the intensities.
|
||||
export material mx_add_edf(
|
||||
material mxp_in1 = material() [[ anno::usage( "materialx:edf") ]],
|
||||
material mxp_in2 = material() [[ anno::usage( "materialx:edf") ]]
|
||||
) [[
|
||||
anno::usage( "materialx:edf")
|
||||
]]
|
||||
= material(
|
||||
surface: material_surface(
|
||||
emission: material_emission(
|
||||
emission: df::unbounded_mix(
|
||||
df::edf_component[](
|
||||
df::edf_component( 1.0, mxp_in1.surface.emission.emission),
|
||||
df::edf_component( 1.0, mxp_in2.surface.emission.emission))
|
||||
),
|
||||
intensity: mxp_in1.surface.emission.intensity + mxp_in2.surface.emission.intensity
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
export material mx_mix_edf(
|
||||
material mxp_fg = material() [[ anno::usage( "materialx:edf") ]],
|
||||
material mxp_bg = material() [[ anno::usage( "materialx:edf") ]],
|
||||
float mxp_mix = 0.0
|
||||
) [[
|
||||
anno::usage( "materialx:edf")
|
||||
]]
|
||||
= let {
|
||||
float mix = math::saturate(mxp_mix);
|
||||
} in material(
|
||||
surface: material_surface(
|
||||
emission: material_emission(
|
||||
emission: df::unbounded_mix(
|
||||
df::edf_component[](
|
||||
df::edf_component( mix, mxp_fg.surface.emission.emission),
|
||||
df::edf_component( 1.0 - mix, mxp_bg.surface.emission.emission))
|
||||
),
|
||||
intensity: mix * mxp_fg.surface.emission.intensity +
|
||||
(1.0 - mix) * mxp_bg.surface.emission.intensity
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// NOTE: Adding two VDFs is not supported in MDL, the generator would best
|
||||
// analyze the context for mixing weights and replace the add with a mix.
|
||||
// The provided implementation just mixes the VDFs with equal weight.
|
||||
export material mx_add_vdf(
|
||||
material mxp_in1 = material() [[ anno::usage( "materialx:vdf") ]],
|
||||
material mxp_in2 = material() [[ anno::usage( "materialx:vdf") ]]
|
||||
) [[
|
||||
anno::usage( "materialx:vdf")
|
||||
]]
|
||||
= let {
|
||||
volume_mix_return v = volume_mix(
|
||||
mxp_in1.volume.scattering_coefficient, 1.0f,
|
||||
mxp_in2.volume.scattering_coefficient, 1.0f);
|
||||
} in material(
|
||||
// assuming mixing the IOR is the best we can do here
|
||||
ior: 0.5 * mxp_in1.ior + 0.5 * mxp_in2.ior,
|
||||
volume: material_volume(
|
||||
scattering: df::unbounded_mix(
|
||||
df::vdf_component[](
|
||||
df::vdf_component( v.mix_weight1, mxp_in1.volume.scattering),
|
||||
df::vdf_component( 1.0 - v.mix_weight1, mxp_in2.volume.scattering))
|
||||
),
|
||||
absorption_coefficient: mxp_in1.volume.absorption_coefficient +
|
||||
mxp_in2.volume.absorption_coefficient,
|
||||
scattering_coefficient: v.scattering_coefficient
|
||||
)
|
||||
);
|
||||
|
||||
export material mx_generalized_schlick_edf(
|
||||
color mxp_color0 = color(1.0),
|
||||
color mxp_color90 = color(1.0),
|
||||
float mxp_exponent = 5.0,
|
||||
material mxp_base = material() [[ anno::usage( "materialx:bsdf") ]]
|
||||
) [[
|
||||
anno::usage( "materialx:edf")
|
||||
]]
|
||||
= material(
|
||||
thin_walled: mxp_base.thin_walled,
|
||||
surface: material_surface(
|
||||
scattering: mxp_base.surface.scattering,
|
||||
emission: material_emission(
|
||||
emission: df::directional_factor(mxp_color0, mxp_color90, mxp_exponent, mxp_base.surface.emission.emission),
|
||||
intensity: mxp_base.surface.emission.intensity,
|
||||
mode: mxp_base.surface.emission.mode)
|
||||
),
|
||||
backface: mxp_base.backface,
|
||||
ior: mxp_base.ior,
|
||||
volume: mxp_base.volume,
|
||||
geometry: mxp_base.geometry,
|
||||
hair: mxp_base.hair
|
||||
);
|
||||
|
||||
// MDL 1.7, Volumes do support emission, but not as EDF, just emission intensity.
|
||||
// A uniform emission DF is the only practical DF here.
|
||||
export material mx_volume(
|
||||
material mxp_vdf = material() [[ anno::usage( "materialx:vdf") ]],
|
||||
material mxp_edf = material() [[ anno::usage( "materialx:edf") ]]
|
||||
) [[
|
||||
anno::usage( "materialx:volumeshader")
|
||||
]]
|
||||
= material(
|
||||
volume: material_volume(
|
||||
absorption_coefficient: mxp_vdf.volume.absorption_coefficient,
|
||||
scattering_coefficient: mxp_vdf.volume.scattering_coefficient,
|
||||
emission_intensity: mxp_edf.surface.emission.intensity
|
||||
)
|
||||
);
|
||||
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// MDL implementation of all types and nodes of
|
||||
// MaterialX Physically-Based Shading Nodes
|
||||
// Document v1.37 REV2, July 16, 2019 (Revised October 17, 2019)
|
||||
// see www.materialx.org
|
||||
// in
|
||||
// NVIDIA Material Definition Language 1.8
|
||||
// Language Specification
|
||||
// Document version 1.8.2, May 24, 2023
|
||||
// www.nvidia.com/mdl
|
||||
|
||||
mdl 1.8;
|
||||
|
||||
// Changes since MDL 1.7
|
||||
// - Support thin-film on custom curve layer to improve generalized_schlick_bsdf,
|
||||
// no new implementation required
|
||||
|
||||
// forward all unchanged definitions from the previous version
|
||||
export using .::pbrlib_1_7 import *;
|
||||
|
||||
// without changing any source code
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
//
|
||||
// Copyright Contributors to the MaterialX Project
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
mdl 1.6;
|
||||
|
||||
import ::math::*;
|
||||
|
||||
import .::core::*;
|
||||
|
||||
// Restrict to 7x7 kernel size for performance reasons
|
||||
export const int MX_MAX_SAMPLE_COUNT = 49;
|
||||
// Size of all weights for all levels (including level 1)
|
||||
export const int MX_WEIGHT_ARRAY_SIZE = 84;
|
||||
|
||||
// This is not available in MDL so just use a "small" number
|
||||
float2 dFdx(float2 uv)
|
||||
{
|
||||
return uv+0.0001;
|
||||
}
|
||||
|
||||
float2 dFdy(float2 uv)
|
||||
{
|
||||
return uv+0.0001;
|
||||
}
|
||||
|
||||
//
|
||||
// Function to compute the sample size relative to a texture coordinate
|
||||
//
|
||||
export float2 mx_compute_sample_size_uv(float2 uv, float filterSize, float filterOffset)
|
||||
{
|
||||
float2 derivUVx = dFdx(uv) * 0.5f;
|
||||
float2 derivUVy = dFdy(uv) * 0.5f;
|
||||
float derivX = ::math::abs(derivUVx.x) + ::math::abs(derivUVy.x);
|
||||
float derivY = ::math::abs(derivUVx.y) + ::math::abs(derivUVy.y);
|
||||
float sampleSizeU = 2.0f * filterSize * derivX + filterOffset;
|
||||
if (sampleSizeU < 1.0E-05f)
|
||||
sampleSizeU = 1.0E-05f;
|
||||
float sampleSizeV = 2.0f * filterSize * derivY + filterOffset;
|
||||
if (sampleSizeV < 1.0E-05f)
|
||||
sampleSizeV = 1.0E-05f;
|
||||
return float2(sampleSizeU, sampleSizeV);
|
||||
}
|
||||
|
||||
//
|
||||
// Compute a normal mapped to 0..1 space based on a set of input
|
||||
// samples using a Sobel filter.
|
||||
//
|
||||
export float3 mx_normal_from_samples_sobel(float[9] S, float scale)
|
||||
{
|
||||
float nx = S[0] - S[2] + (2.0*S[3]) - (2.0*S[5]) + S[6] - S[8];
|
||||
float ny = S[0] + (2.0*S[1]) + S[2] - S[6] - (2.0*S[7]) - S[8];
|
||||
float nz = scale * ::math::sqrt(1.0 - nx*nx - ny*ny);
|
||||
float3 norm = ::math::normalize(float3(nx, ny, nz));
|
||||
return (norm + 1.0) * 0.5;
|
||||
}
|
||||
|
||||
// Kernel weights for box filter
|
||||
export float[MX_MAX_SAMPLE_COUNT] mx_get_box_weights(int filterSize)
|
||||
{
|
||||
float[MX_MAX_SAMPLE_COUNT] W;
|
||||
int sampleCount = filterSize*filterSize;
|
||||
float value = 1.0 / float(sampleCount);
|
||||
for (int i=0; i<sampleCount; i++)
|
||||
{
|
||||
W[i] = value;
|
||||
}
|
||||
return W;
|
||||
}
|
||||
|
||||
// Kernel weights for Gaussian filter. Sigma is assumed to be 1.
|
||||
export float[MX_MAX_SAMPLE_COUNT] mx_get_gaussian_weights(int filterSize)
|
||||
{
|
||||
float[MX_MAX_SAMPLE_COUNT] W;
|
||||
if (filterSize >= 7)
|
||||
{
|
||||
W[0] = 0.000036; W[1] = 0.000363; W[2] = 0.001446; W[3] = 0.002291; W[4] = 0.001446; W[5] = 0.000363; W[6] = 0.000036;
|
||||
W[7] = 0.000363; W[8] = 0.003676; W[9] = 0.014662; W[10] = 0.023226; W[11] = 0.014662; W[12] = 0.003676; W[13] = 0.000363;
|
||||
W[14] = 0.001446; W[15] = 0.014662; W[16] = 0.058488; W[17] = 0.092651; W[18] = 0.058488; W[19] = 0.014662; W[20] = 0.001446;
|
||||
W[21] = 0.002291; W[22] = 0.023226; W[23] = 0.092651; W[24] = 0.146768; W[25] = 0.092651; W[26] = 0.023226; W[27] = 0.002291;
|
||||
W[28] = 0.001446; W[29] = 0.014662; W[30] = 0.058488; W[31] = 0.092651; W[32] = 0.058488; W[33] = 0.014662; W[34] = 0.001446;
|
||||
W[35] = 0.000363; W[36] = 0.003676; W[37] = 0.014662; W[38] = 0.023226; W[39] = 0.014662; W[40] = 0.003676; W[41] = 0.000363;
|
||||
W[42] = 0.000036; W[43] = 0.000363; W[44] = 0.001446; W[45] = 0.002291; W[46] = 0.001446; W[47] = 0.000363; W[48] = 0.000036;
|
||||
}
|
||||
else if (filterSize >= 5)
|
||||
{
|
||||
W[0] = 0.003765; W[1] = 0.015019; W[2] = 0.023792; W[3] = 0.015019; W[4] = 0.003765;
|
||||
W[5] = 0.015019; W[6] = 0.059912; W[7] = 0.094907; W[8] = 0.059912; W[9] = 0.015019;
|
||||
W[10] = 0.023792; W[11] = 0.094907; W[12] = 0.150342; W[13] = 0.094907; W[14] = 0.023792;
|
||||
W[15] = 0.015019; W[16] = 0.059912; W[17] = 0.094907; W[18] = 0.059912; W[19] = 0.015019;
|
||||
W[20] = 0.003765; W[21] = 0.015019; W[22] = 0.023792; W[23] = 0.015019; W[24] = 0.003765;
|
||||
}
|
||||
else if (filterSize >= 3)
|
||||
{
|
||||
W[0] = 0.0625; W[1] = 0.125; W[2] = 0.0625;
|
||||
W[3] = 0.125; W[4] = 0.25; W[5] = 0.125;
|
||||
W[6] = 0.0625; W[7] = 0.125; W[8] = 0.0625;
|
||||
}
|
||||
else
|
||||
{
|
||||
W[0] = 1.0;
|
||||
}
|
||||
return W;
|
||||
}
|
||||
|
||||
//
|
||||
// Apply filter for float samples S, using weights W.
|
||||
// sampleCount should be a square of a odd number in the range { 1, 3, 5, 7 }
|
||||
//
|
||||
export float mx_convolution_float(float[MX_MAX_SAMPLE_COUNT] S, float[MX_WEIGHT_ARRAY_SIZE] W, int offset, int sampleCount)
|
||||
{
|
||||
float result = 0.0;
|
||||
for (int i = 0; i < sampleCount; i++)
|
||||
{
|
||||
result += S[i]*W[i+offset];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Apply filter for float2 samples S, using weights W.
|
||||
// sampleCount should be a square of a odd number in the range { 1, 3, 5, 7 }
|
||||
//
|
||||
export float2 mx_convolution_float2(float2[MX_MAX_SAMPLE_COUNT] S, float[MX_WEIGHT_ARRAY_SIZE] W, int offset, int sampleCount)
|
||||
{
|
||||
float2 result = float2(0.0);
|
||||
for (int i=0; i<sampleCount; i++)
|
||||
{
|
||||
result += S[i]*W[i+offset];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Apply filter for float3 samples S, using weights W.
|
||||
// sampleCount should be a square of a odd number in the range { 1, 3, 5, 7 }
|
||||
//
|
||||
export float3 mx_convolution_float3(float3[MX_MAX_SAMPLE_COUNT] S, float[MX_WEIGHT_ARRAY_SIZE] W, int offset, int sampleCount)
|
||||
{
|
||||
float3 result = float3(0.0);
|
||||
for (int i=0; i<sampleCount; i++)
|
||||
{
|
||||
result += S[i]*W[i+offset];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Apply filter for float4 samples S, using weights W.
|
||||
// sampleCount should be a square of a odd number { 1, 3, 5, 7 }
|
||||
//
|
||||
export float4 mx_convolution_float4(float4[MX_MAX_SAMPLE_COUNT] S, float[MX_WEIGHT_ARRAY_SIZE] W, int offset, int sampleCount)
|
||||
{
|
||||
float4 result = float4(0.0);
|
||||
for (int i=0; i<sampleCount; i++)
|
||||
{
|
||||
result += S[i]*W[i+offset];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export color mx_convolution_color(color[MX_MAX_SAMPLE_COUNT] S, float[MX_WEIGHT_ARRAY_SIZE] W, int offset, int sampleCount)
|
||||
{
|
||||
color result = color(0.0);
|
||||
for (int i=0; i<sampleCount; i++)
|
||||
{
|
||||
result += S[i]*W[i+offset];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export core::color4 mx_convolution_color4(core::color4[MX_MAX_SAMPLE_COUNT] S, float[MX_WEIGHT_ARRAY_SIZE] W, int offset, int sampleCount)
|
||||
{
|
||||
core::color4 result = core::mk_color4(0.0, 0.0, 0.0, 0.0);
|
||||
for (int i=0; i<sampleCount; i++)
|
||||
{
|
||||
core::mx_add(result, core::mx_multiply(S[i], W[i+offset]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Copyright Contributors to the MaterialX Project
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
// MDL implementation of all Standard Source Nodes of
|
||||
// MaterialX: An Open Standard for Network-Based CG Object Looks
|
||||
// Document v1.37 REV2, January 19, 2020
|
||||
// www.materialx.org
|
||||
// in
|
||||
// NVIDIA Material Definition Language 1.7
|
||||
// Language Specification
|
||||
// Document version 1.7.2, January 17, 2022
|
||||
// www.nvidia.com/mdl
|
||||
|
||||
mdl 1.8;
|
||||
|
||||
// forward the latest version
|
||||
export using .::stdlib_1_8 import *;
|
||||
Vendored
+4578
File diff suppressed because it is too large
Load Diff
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Copyright Contributors to the MaterialX Project
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
// MDL implementation of all Standard Source Nodes of
|
||||
// MaterialX: An Open Standard for Network-Based CG Object Looks
|
||||
// Document v1.37 REV2, January 19, 2020
|
||||
// www.materialx.org
|
||||
// in
|
||||
// NVIDIA Material Definition Language 1.7
|
||||
// Language Specification
|
||||
// Document version 1.7.2, January 17, 2022
|
||||
// www.nvidia.com/mdl
|
||||
|
||||
mdl 1.7;
|
||||
|
||||
// forward all unchanged definitions from the previous version
|
||||
export using .::stdlib_1_6 import *;
|
||||
Vendored
+449
@@ -0,0 +1,449 @@
|
||||
//
|
||||
// Copyright Contributors to the MaterialX Project
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
// MDL implementation of all Standard Source Nodes of
|
||||
// MaterialX: An Open Standard for Network-Based CG Object Looks
|
||||
// Document v1.37 REV2, January 19, 2020
|
||||
// www.materialx.org
|
||||
// in
|
||||
// NVIDIA Material Definition Language 1.8
|
||||
// Language Specification
|
||||
// Document version 1.8.2, May 24, 2023
|
||||
// www.nvidia.com/mdl
|
||||
|
||||
mdl 1.8;
|
||||
|
||||
import ::anno::*;
|
||||
import ::math::*;
|
||||
import ::scene::*;
|
||||
import ::state::*;
|
||||
|
||||
import .::core::*;
|
||||
import .::noise::*;
|
||||
import .::swizzle::*;
|
||||
import .::hsv::*;
|
||||
|
||||
// Changes since MDL 1.7
|
||||
// - Scene data lookups used for PrimVar readers allow non-literal string names
|
||||
|
||||
// forward all unchanged definitions from the previous version
|
||||
export using .::stdlib_1_7 import mx_surfacematerial;
|
||||
export using .::stdlib_1_7 import mx_surface_unlit;
|
||||
export using .::stdlib_1_7 import mx_image_float;
|
||||
export using .::stdlib_1_7 import mx_image_color3;
|
||||
export using .::stdlib_1_7 import mx_image_color4;
|
||||
export using .::stdlib_1_7 import mx_image_vector2;
|
||||
export using .::stdlib_1_7 import mx_image_vector3;
|
||||
export using .::stdlib_1_7 import mx_image_vector4;
|
||||
export using .::stdlib_1_7 import mx_constant_float;
|
||||
export using .::stdlib_1_7 import mx_constant_color3;
|
||||
export using .::stdlib_1_7 import mx_constant_color4;
|
||||
export using .::stdlib_1_7 import mx_constant_vector2;
|
||||
export using .::stdlib_1_7 import mx_constant_vector3;
|
||||
export using .::stdlib_1_7 import mx_constant_vector4;
|
||||
export using .::stdlib_1_7 import mx_constant_boolean;
|
||||
export using .::stdlib_1_7 import mx_constant_integer;
|
||||
export using .::stdlib_1_7 import mx_constant_matrix33;
|
||||
export using .::stdlib_1_7 import mx_constant_matrix44;
|
||||
export using .::stdlib_1_7 import mx_constant_string;
|
||||
export using .::stdlib_1_7 import mx_constant_filename;
|
||||
export using .::stdlib_1_7 import mx_ramplr_float;
|
||||
export using .::stdlib_1_7 import mx_ramplr_color3;
|
||||
export using .::stdlib_1_7 import mx_ramplr_color4;
|
||||
export using .::stdlib_1_7 import mx_ramplr_vector2;
|
||||
export using .::stdlib_1_7 import mx_ramplr_vector3;
|
||||
export using .::stdlib_1_7 import mx_ramplr_vector4;
|
||||
export using .::stdlib_1_7 import mx_ramptb_float;
|
||||
export using .::stdlib_1_7 import mx_ramptb_color3;
|
||||
export using .::stdlib_1_7 import mx_ramptb_color4;
|
||||
export using .::stdlib_1_7 import mx_ramptb_vector2;
|
||||
export using .::stdlib_1_7 import mx_ramptb_vector3;
|
||||
export using .::stdlib_1_7 import mx_ramptb_vector4;
|
||||
export using .::stdlib_1_7 import mx_splitlr_float;
|
||||
export using .::stdlib_1_7 import mx_splitlr_color3;
|
||||
export using .::stdlib_1_7 import mx_splitlr_color4;
|
||||
export using .::stdlib_1_7 import mx_splitlr_vector2;
|
||||
export using .::stdlib_1_7 import mx_splitlr_vector3;
|
||||
export using .::stdlib_1_7 import mx_splitlr_vector4;
|
||||
export using .::stdlib_1_7 import mx_splittb_float;
|
||||
export using .::stdlib_1_7 import mx_splittb_color3;
|
||||
export using .::stdlib_1_7 import mx_splittb_color4;
|
||||
export using .::stdlib_1_7 import mx_splittb_vector2;
|
||||
export using .::stdlib_1_7 import mx_splittb_vector3;
|
||||
export using .::stdlib_1_7 import mx_splittb_vector4;
|
||||
export using .::stdlib_1_7 import mx_position_vector3;
|
||||
export using .::stdlib_1_7 import mx_normal_vector3;
|
||||
export using .::stdlib_1_7 import mx_tangent_vector3;
|
||||
export using .::stdlib_1_7 import mx_bitangent_vector3;
|
||||
export using .::stdlib_1_7 import mx_texcoord_vector2;
|
||||
export using .::stdlib_1_7 import mx_texcoord_vector3;
|
||||
export using .::stdlib_1_7 import mx_geomcolor_float;
|
||||
export using .::stdlib_1_7 import mx_geomcolor_color3;
|
||||
export using .::stdlib_1_7 import mx_geomcolor_color4;
|
||||
export using .::stdlib_1_7 import mx_ambientocclusion_float;
|
||||
export using .::stdlib_1_7 import mx_frame_float;
|
||||
export using .::stdlib_1_7 import mx_time_float;
|
||||
export using .::stdlib_1_7 import mx_modulo_color3;
|
||||
export using .::stdlib_1_7 import mx_modulo_color4;
|
||||
export using .::stdlib_1_7 import mx_modulo_color3FA;
|
||||
export using .::stdlib_1_7 import mx_modulo_color4FA;
|
||||
export using .::stdlib_1_7 import mx_invert_color4;
|
||||
export using .::stdlib_1_7 import mx_invert_color4FA;
|
||||
export using .::stdlib_1_7 import mx_absval_color4;
|
||||
export using .::stdlib_1_7 import mx_floor_color3;
|
||||
export using .::stdlib_1_7 import mx_floor_color4;
|
||||
export using .::stdlib_1_7 import mx_ceil_color3;
|
||||
export using .::stdlib_1_7 import mx_ceil_color4;
|
||||
export using .::stdlib_1_7 import mx_round_color3;
|
||||
export using .::stdlib_1_7 import mx_round_color4;
|
||||
export using .::stdlib_1_7 import mx_power_color4;
|
||||
export using .::stdlib_1_7 import mx_power_color4FA;
|
||||
export using .::stdlib_1_7 import mx_sin_float;
|
||||
export using .::stdlib_1_7 import mx_cos_float;
|
||||
export using .::stdlib_1_7 import mx_tan_float;
|
||||
export using .::stdlib_1_7 import mx_asin_float;
|
||||
export using .::stdlib_1_7 import mx_acos_float;
|
||||
export using .::stdlib_1_7 import mx_atan2_float;
|
||||
export using .::stdlib_1_7 import mx_sin_vector2;
|
||||
export using .::stdlib_1_7 import mx_cos_vector2;
|
||||
export using .::stdlib_1_7 import mx_tan_vector2;
|
||||
export using .::stdlib_1_7 import mx_asin_vector2;
|
||||
export using .::stdlib_1_7 import mx_acos_vector2;
|
||||
export using .::stdlib_1_7 import mx_atan2_vector2;
|
||||
export using .::stdlib_1_7 import mx_sin_vector3;
|
||||
export using .::stdlib_1_7 import mx_cos_vector3;
|
||||
export using .::stdlib_1_7 import mx_tan_vector3;
|
||||
export using .::stdlib_1_7 import mx_asin_vector3;
|
||||
export using .::stdlib_1_7 import mx_acos_vector3;
|
||||
export using .::stdlib_1_7 import mx_atan2_vector3;
|
||||
export using .::stdlib_1_7 import mx_sin_vector4;
|
||||
export using .::stdlib_1_7 import mx_cos_vector4;
|
||||
export using .::stdlib_1_7 import mx_tan_vector4;
|
||||
export using .::stdlib_1_7 import mx_asin_vector4;
|
||||
export using .::stdlib_1_7 import mx_acos_vector4;
|
||||
export using .::stdlib_1_7 import mx_atan2_vector4;
|
||||
export using .::stdlib_1_7 import mx_sqrt_float;
|
||||
export using .::stdlib_1_7 import mx_ln_float;
|
||||
export using .::stdlib_1_7 import mx_exp_float;
|
||||
export using .::stdlib_1_7 import mx_sqrt_vector2;
|
||||
export using .::stdlib_1_7 import mx_ln_vector2;
|
||||
export using .::stdlib_1_7 import mx_exp_vector2;
|
||||
export using .::stdlib_1_7 import mx_sqrt_vector3;
|
||||
export using .::stdlib_1_7 import mx_ln_vector3;
|
||||
export using .::stdlib_1_7 import mx_exp_vector3;
|
||||
export using .::stdlib_1_7 import mx_sqrt_vector4;
|
||||
export using .::stdlib_1_7 import mx_ln_vector4;
|
||||
export using .::stdlib_1_7 import mx_exp_vector4;
|
||||
export using .::stdlib_1_7 import mx_sign_color3;
|
||||
export using .::stdlib_1_7 import mx_sign_color4;
|
||||
export using .::stdlib_1_7 import mx_clamp_color4;
|
||||
export using .::stdlib_1_7 import mx_clamp_color4FA;
|
||||
export using .::stdlib_1_7 import mx_min_color4;
|
||||
export using .::stdlib_1_7 import mx_min_color4;
|
||||
export using .::stdlib_1_7 import mx_max_color4;
|
||||
export using .::stdlib_1_7 import mx_max_color4;
|
||||
export using .::stdlib_1_7 import mx_transformpoint_vector3;
|
||||
export using .::stdlib_1_7 import mx_transformvector_vector3;
|
||||
export using .::stdlib_1_7 import mx_transformnormal_vector3;
|
||||
export using .::stdlib_1_7 import mx_transformmatrix_vector2M3;
|
||||
export using .::stdlib_1_7 import mx_transformmatrix_vector3;
|
||||
export using .::stdlib_1_7 import mx_transformmatrix_vector3M4;
|
||||
export using .::stdlib_1_7 import mx_transformmatrix_vector4;
|
||||
export using .::stdlib_1_7 import mx_normalmap_float;
|
||||
export using .::stdlib_1_7 import mx_normalmap_vector2;
|
||||
export using .::stdlib_1_7 import mx_transpose_matrix33;
|
||||
export using .::stdlib_1_7 import mx_transpose_matrix44;
|
||||
export using .::stdlib_1_7 import mx_determinant_matrix33;
|
||||
export using .::stdlib_1_7 import mx_determinant_matrix44;
|
||||
export using .::stdlib_1_7 import mx_invertmatrix_matrix33;
|
||||
export using .::stdlib_1_7 import mx_invertmatrix_matrix44;
|
||||
export using .::stdlib_1_7 import mx_rotate2d_vector2;
|
||||
export using .::stdlib_1_7 import mx_rotate3d_vector3;
|
||||
export using .::stdlib_1_7 import mx_remap_float;
|
||||
export using .::stdlib_1_7 import mx_remap_color3;
|
||||
export using .::stdlib_1_7 import mx_remap_color4;
|
||||
export using .::stdlib_1_7 import mx_remap_vector2;
|
||||
export using .::stdlib_1_7 import mx_remap_vector3;
|
||||
export using .::stdlib_1_7 import mx_remap_vector4;
|
||||
export using .::stdlib_1_7 import mx_remap_color3FA;
|
||||
export using .::stdlib_1_7 import mx_remap_color4FA;
|
||||
export using .::stdlib_1_7 import mx_remap_vector2FA;
|
||||
export using .::stdlib_1_7 import mx_remap_vector3FA;
|
||||
export using .::stdlib_1_7 import mx_remap_vector4FA;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_float;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_color3;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_color4;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_vector2;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_vector3;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_vector4;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_color3FA;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_color4FA;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_vector2FA;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_vector3FA;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_vector4FA;
|
||||
export using .::stdlib_1_7 import mx_curveadjust_float;
|
||||
export using .::stdlib_1_7 import mx_curveadjust_color3;
|
||||
export using .::stdlib_1_7 import mx_curveadjust_color4;
|
||||
export using .::stdlib_1_7 import mx_curveadjust_vector2;
|
||||
export using .::stdlib_1_7 import mx_curveadjust_vector3;
|
||||
export using .::stdlib_1_7 import mx_curveadjust_vector4;
|
||||
export using .::stdlib_1_7 import mx_luminance_color3;
|
||||
export using .::stdlib_1_7 import mx_luminance_color4;
|
||||
export using .::stdlib_1_7 import mx_rgbtohsv_color3;
|
||||
export using .::stdlib_1_7 import mx_rgbtohsv_color4;
|
||||
export using .::stdlib_1_7 import mx_hsvtorgb_color3;
|
||||
export using .::stdlib_1_7 import mx_hsvtorgb_color4;
|
||||
export using .::stdlib_1_7 import mx_premult_color4;
|
||||
export using .::stdlib_1_7 import mx_unpremult_color4;
|
||||
export using .::stdlib_1_7 import mx_plus_color4;
|
||||
export using .::stdlib_1_7 import mx_minus_color4;
|
||||
export using .::stdlib_1_7 import mx_difference_color4;
|
||||
export using .::stdlib_1_7 import mx_burn_float;
|
||||
export using .::stdlib_1_7 import mx_burn_color3;
|
||||
export using .::stdlib_1_7 import mx_burn_color4;
|
||||
export using .::stdlib_1_7 import mx_dodge_float;
|
||||
export using .::stdlib_1_7 import mx_dodge_color3;
|
||||
export using .::stdlib_1_7 import mx_dodge_color4;
|
||||
export using .::stdlib_1_7 import mx_screen_color4;
|
||||
export using .::stdlib_1_7 import mx_disjointover_color4;
|
||||
export using .::stdlib_1_7 import mx_in_color4;
|
||||
export using .::stdlib_1_7 import mx_mask_color4;
|
||||
export using .::stdlib_1_7 import mx_matte_color4;
|
||||
export using .::stdlib_1_7 import mx_out_color4;
|
||||
export using .::stdlib_1_7 import mx_over_color4;
|
||||
export using .::stdlib_1_7 import mx_mix_color4;
|
||||
export using .::stdlib_1_7 import mx_mix_color4_color4;
|
||||
export using .::stdlib_1_7 import mx_mix_surfaceshader;
|
||||
export using .::stdlib_1_7 import mx_mix_volumeshader;
|
||||
export using .::stdlib_1_7 import mx_mix_displacementshader;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_float;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_color3;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_color4;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_vector2;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_vector3;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_vector4;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_floatI;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_color3I;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_color4I;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_vector2I;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_vector3I;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_vector4I;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_float;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_color3;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_color4;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_vector2;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_vector3;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_vector4;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_floatI;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_color3I;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_color4I;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_vector2I;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_vector3I;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_vector4I;
|
||||
export using .::stdlib_1_7 import mx_ifequal_float;
|
||||
export using .::stdlib_1_7 import mx_ifequal_color3;
|
||||
export using .::stdlib_1_7 import mx_ifequal_color4;
|
||||
export using .::stdlib_1_7 import mx_ifequal_vector2;
|
||||
export using .::stdlib_1_7 import mx_ifequal_vector3;
|
||||
export using .::stdlib_1_7 import mx_ifequal_vector4;
|
||||
export using .::stdlib_1_7 import mx_ifequal_floatI;
|
||||
export using .::stdlib_1_7 import mx_ifequal_color3I;
|
||||
export using .::stdlib_1_7 import mx_ifequal_color4I;
|
||||
export using .::stdlib_1_7 import mx_ifequal_vector2I;
|
||||
export using .::stdlib_1_7 import mx_ifequal_vector3I;
|
||||
export using .::stdlib_1_7 import mx_ifequal_vector4I;
|
||||
export using .::stdlib_1_7 import mx_ifequal_floatB;
|
||||
export using .::stdlib_1_7 import mx_ifequal_color3B;
|
||||
export using .::stdlib_1_7 import mx_ifequal_color4B;
|
||||
export using .::stdlib_1_7 import mx_ifequal_vector2B;
|
||||
export using .::stdlib_1_7 import mx_ifequal_vector3B;
|
||||
export using .::stdlib_1_7 import mx_ifequal_vector4B;
|
||||
export using .::stdlib_1_7 import mx_switch_float;
|
||||
export using .::stdlib_1_7 import mx_switch_color3;
|
||||
export using .::stdlib_1_7 import mx_switch_color4;
|
||||
export using .::stdlib_1_7 import mx_switch_vector2;
|
||||
export using .::stdlib_1_7 import mx_switch_vector3;
|
||||
export using .::stdlib_1_7 import mx_switch_vector4;
|
||||
export using .::stdlib_1_7 import mx_switch_floatI;
|
||||
export using .::stdlib_1_7 import mx_switch_color3I;
|
||||
export using .::stdlib_1_7 import mx_switch_color4I;
|
||||
export using .::stdlib_1_7 import mx_switch_vector2I;
|
||||
export using .::stdlib_1_7 import mx_switch_vector3I;
|
||||
export using .::stdlib_1_7 import mx_switch_vector4I;
|
||||
export using .::stdlib_1_7 import mx_convert_float_color3;
|
||||
export using .::stdlib_1_7 import mx_convert_float_color4;
|
||||
export using .::stdlib_1_7 import mx_convert_float_vector2;
|
||||
export using .::stdlib_1_7 import mx_convert_float_vector3;
|
||||
export using .::stdlib_1_7 import mx_convert_float_vector4;
|
||||
export using .::stdlib_1_7 import mx_convert_vector2_vector3;
|
||||
export using .::stdlib_1_7 import mx_convert_vector3_color3;
|
||||
export using .::stdlib_1_7 import mx_convert_vector3_vector2;
|
||||
export using .::stdlib_1_7 import mx_convert_vector3_vector4;
|
||||
export using .::stdlib_1_7 import mx_convert_vector4_color4;
|
||||
export using .::stdlib_1_7 import mx_convert_vector4_vector3;
|
||||
export using .::stdlib_1_7 import mx_convert_color3_vector3;
|
||||
export using .::stdlib_1_7 import mx_convert_color4_vector4;
|
||||
export using .::stdlib_1_7 import mx_convert_color3_color4;
|
||||
export using .::stdlib_1_7 import mx_convert_color4_color3;
|
||||
export using .::stdlib_1_7 import mx_convert_boolean_float;
|
||||
export using .::stdlib_1_7 import mx_convert_integer_float;
|
||||
export using .::stdlib_1_7 import mx_combine2_vector2;
|
||||
export using .::stdlib_1_7 import mx_combine2_color4CF;
|
||||
export using .::stdlib_1_7 import mx_combine2_vector4VF;
|
||||
export using .::stdlib_1_7 import mx_combine2_color4CC;
|
||||
export using .::stdlib_1_7 import mx_combine2_vector4VV;
|
||||
export using .::stdlib_1_7 import mx_combine3_color3;
|
||||
export using .::stdlib_1_7 import mx_combine3_vector3;
|
||||
export using .::stdlib_1_7 import mx_combine4_color4;
|
||||
export using .::stdlib_1_7 import mx_combine4_vector4;
|
||||
export using .::stdlib_1_7 import mx_creatematrix_vector3_matrix33;
|
||||
export using .::stdlib_1_7 import mx_creatematrix_vector3_matrix44;
|
||||
export using .::stdlib_1_7 import mx_creatematrix_vector4_matrix44;
|
||||
export using .::stdlib_1_7 import mx_blur_float;
|
||||
export using .::stdlib_1_7 import mx_blur_color3;
|
||||
export using .::stdlib_1_7 import mx_blur_color4;
|
||||
export using .::stdlib_1_7 import mx_blur_vector2;
|
||||
export using .::stdlib_1_7 import mx_blur_vector3;
|
||||
export using .::stdlib_1_7 import mx_blur_vector4;
|
||||
export using .::stdlib_1_7 import mx_heighttonormal_vector3;
|
||||
export using .::stdlib_1_7 import mx_noise2d_float;
|
||||
export using .::stdlib_1_7 import mx_noise2d_float2;
|
||||
export using .::stdlib_1_7 import mx_noise2d_float3;
|
||||
export using .::stdlib_1_7 import mx_noise2d_float4;
|
||||
export using .::stdlib_1_7 import mx_noise3d_float;
|
||||
export using .::stdlib_1_7 import mx_noise3d_float2;
|
||||
export using .::stdlib_1_7 import mx_noise3d_float3;
|
||||
export using .::stdlib_1_7 import mx_noise3d_float4;
|
||||
export using .::stdlib_1_7 import mx_fractal3d_float;
|
||||
export using .::stdlib_1_7 import mx_fractal3d_float2;
|
||||
export using .::stdlib_1_7 import mx_fractal3d_float3;
|
||||
export using .::stdlib_1_7 import mx_fractal3d_float4;
|
||||
export using .::stdlib_1_7 import mx_cellnoise2d_float;
|
||||
export using .::stdlib_1_7 import mx_cellnoise3d_float;
|
||||
export using .::stdlib_1_7 import mx_worleynoise2d_float;
|
||||
export using .::stdlib_1_7 import mx_worleynoise2d_float2;
|
||||
export using .::stdlib_1_7 import mx_worleynoise2d_float3;
|
||||
export using .::stdlib_1_7 import mx_worleynoise3d_float;
|
||||
export using .::stdlib_1_7 import mx_worleynoise3d_float2;
|
||||
export using .::stdlib_1_7 import mx_worleynoise3d_float3;
|
||||
|
||||
// NOTE: Not planned to be implemented.
|
||||
export using .::stdlib_1_7 import mx_geompropvalue_string;
|
||||
|
||||
// NOTE: No boolean scene data in MDL so it's mapped to integer.
|
||||
// Returns false if the scene data is zero, true otherwise.
|
||||
export bool mx_geompropvalue_boolean(
|
||||
uniform string mxp_geomprop = string(""),
|
||||
bool mxp_default = bool(false)
|
||||
)
|
||||
[[
|
||||
anno::description("Node Group: geometric")
|
||||
]]
|
||||
{
|
||||
int defaultValue = mxp_default ? 1 : 0;
|
||||
return scene::data_lookup_int(mxp_geomprop, defaultValue) == 0 ? false : true;
|
||||
}
|
||||
|
||||
export int mx_geompropvalue_integer(
|
||||
uniform string mxp_geomprop = string(""),
|
||||
int mxp_default = int(0)
|
||||
)
|
||||
[[
|
||||
anno::description("Node Group: geometric")
|
||||
]]
|
||||
{
|
||||
return scene::data_lookup_int(mxp_geomprop, mxp_default);
|
||||
}
|
||||
|
||||
export float mx_geompropvalue_float(
|
||||
uniform string mxp_geomprop = string(""),
|
||||
float mxp_default = float(0.0)
|
||||
)
|
||||
[[
|
||||
anno::description("Node Group: geometric")
|
||||
]]
|
||||
{
|
||||
return scene::data_lookup_float(mxp_geomprop, mxp_default);
|
||||
}
|
||||
|
||||
export color mx_geompropvalue_color3(
|
||||
uniform string mxp_geomprop = string(""),
|
||||
color mxp_default = color(0.0, 0.0, 0.0)
|
||||
)
|
||||
[[
|
||||
anno::description("Node Group: geometric")
|
||||
]]
|
||||
{
|
||||
return scene::data_lookup_color(mxp_geomprop, mxp_default);
|
||||
}
|
||||
|
||||
export core::color4 mx_geompropvalue_color4(
|
||||
uniform string mxp_geomprop = string(""),
|
||||
core::color4 mxp_default = core::mk_color4(0.0, 0.0, 0.0, 0.0)
|
||||
)
|
||||
[[
|
||||
anno::description("Node Group: geometric")
|
||||
]]
|
||||
{
|
||||
float3 rgbValue = float3(mxp_default.rgb);
|
||||
float4 defaultValue = float4(rgbValue.x, rgbValue.y, rgbValue.z, mxp_default.a);
|
||||
float4 value = scene::data_lookup_float4(mxp_geomprop, defaultValue);
|
||||
return core::mk_color4(value.x, value.y, value.z, value.w);
|
||||
}
|
||||
|
||||
export float2 mx_geompropvalue_vector2(
|
||||
uniform string mxp_geomprop = string(""),
|
||||
float2 mxp_default = float2(0.0, 0.0)
|
||||
)
|
||||
[[
|
||||
anno::description("Node Group: geometric")
|
||||
]]
|
||||
{
|
||||
return scene::data_lookup_float2(mxp_geomprop, mxp_default);
|
||||
}
|
||||
|
||||
export float3 mx_geompropvalue_vector3(
|
||||
uniform string mxp_geomprop = string(""),
|
||||
float3 mxp_default = float3(0.0, 0.0, 0.0)
|
||||
)
|
||||
[[
|
||||
anno::description("Node Group: geometric")
|
||||
]]
|
||||
{
|
||||
return scene::data_lookup_float3(mxp_geomprop, mxp_default);
|
||||
}
|
||||
|
||||
export float4 mx_geompropvalue_vector4(
|
||||
uniform string mxp_geomprop = string(""),
|
||||
float4 mxp_default = float4(0.0, 0.0, 0.0, 0.0)
|
||||
)
|
||||
{
|
||||
return scene::data_lookup_float4(mxp_geomprop, mxp_default);
|
||||
}
|
||||
|
||||
export float3 mx_viewdirection_vector3(
|
||||
uniform core::mx_coordinatespace_type mxp_space = core::mx_coordinatespace_type_world
|
||||
[[
|
||||
anno::description("Enumeration {model,object,world}."),
|
||||
anno::unused()
|
||||
]]
|
||||
)
|
||||
[[
|
||||
anno::description("Node Group: nprlib")
|
||||
]]
|
||||
{
|
||||
float3 internal_space_direction =
|
||||
state::position() - scene::data_lookup_float3("CAMERA_POSITION", float3(0.0, 0.0, 0.0));
|
||||
|
||||
if (mxp_space == core::mx_coordinatespace_type_world)
|
||||
return math::normalize(state::transform_vector(
|
||||
::state::coordinate_internal,
|
||||
::state::coordinate_world,
|
||||
internal_space_direction));
|
||||
else
|
||||
return math::normalize(state::transform_vector(
|
||||
::state::coordinate_internal,
|
||||
::state::coordinate_object,
|
||||
internal_space_direction));
|
||||
}
|
||||
+1007
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user