summaryrefslogtreecommitdiffstats
path: root/pbr_utils.cginc
diff options
context:
space:
mode:
Diffstat (limited to 'pbr_utils.cginc')
-rw-r--r--pbr_utils.cginc20
1 files changed, 20 insertions, 0 deletions
diff --git a/pbr_utils.cginc b/pbr_utils.cginc
new file mode 100644
index 0000000..c8c10cc
--- /dev/null
+++ b/pbr_utils.cginc
@@ -0,0 +1,20 @@
+#ifndef __PBR_UTILS_INC
+#define __PBR_UTILS_INC
+
+float perceptualRoughnessToRoughness(float perceptualRoughness) {
+ return perceptualRoughness * perceptualRoughness;
+}
+
+float roughnessToPerceptualRoughness(float roughness) {
+ return sqrt(roughness);
+}
+
+float smoothnessToPerceptualRoughness(float smoothness) {
+ return 1.0f - smoothness;
+}
+
+float smoothnessToRoughness(float smoothness) {
+ return perceptualRoughnessToRoughness(smoothnessToPerceptualRoughness(smoothness));
+}
+
+#endif // __PBR_UTILS_INC