diff options
| author | yum <yum.food.vr@gmail.com> | 2025-08-06 16:42:42 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-08-06 16:42:42 -0700 |
| commit | 99d161288bfe2d10c331c97e6b7571f9c884e912 (patch) | |
| tree | 6ef130c4801de52f697c8d6996d9c4b0fb5f3964 /pbr.cginc | |
initial commit
Diffstat (limited to 'pbr.cginc')
| -rw-r--r-- | pbr.cginc | 34 |
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 |
