summaryrefslogtreecommitdiffstats
path: root/pbr.cginc
diff options
context:
space:
mode:
Diffstat (limited to 'pbr.cginc')
-rw-r--r--pbr.cginc34
1 files changed, 34 insertions, 0 deletions
diff --git a/pbr.cginc b/pbr.cginc
new file mode 100644
index 0000000..6e37942
--- /dev/null
+++ b/pbr.cginc
@@ -0,0 +1,34 @@
+#ifndef __PBR_INC
+#define __PBR_INC
+
+#include "filamented.cginc"
+#include "globals.cginc"
+#include "interpolators.cginc"
+
+struct Pbr {
+ float4 albedo;
+ float3 normal;
+ float smoothness;
+ float roughness_perceptual;
+ float roughness;
+ float metallic;
+};
+
+// TODO consider normal filtering like filamented
+void propagateSmoothness(inout Pbr pbr) {
+ pbr.roughness_perceptual = max(MIN_PERCEPTUAL_ROUGHNESS, 1.0f - pbr.smoothness);
+ pbr.roughness = max(MIN_ROUGHNESS, pbr.roughness_perceptual * pbr.roughness_perceptual);
+}
+
+Pbr getPbr(v2f i) {
+ Pbr pbr = (Pbr) 0;
+ pbr.normal = float3(0, 1, 0);
+ pbr.albedo = _Color;
+ pbr.smoothness = _Smoothness;
+ propagateSmoothness(pbr);
+
+ pbr.metallic = _Metallic;
+ return pbr;
+}
+
+#endif // __PBR_INC