123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- /*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
- #pragma once
- #ifndef Surface
- #define Surface SurfaceData_EnhancedPBR
- #endif
- #include "../StandardPBR/StandardPBR_SurfaceData.azsli"
- #include <Atom/Features/PBR/Surfaces/AnisotropicSurfaceData.azsli>
- #include <Atom/Features/PBR/Surfaces/TransmissionSurfaceData.azsli>
- // Class inheritance doesn't seem to be working
- #define DOES_CLASS_INHERITANCE_WORK_IN_ASZL 0
- #if DOES_CLASS_INHERITANCE_WORK_IN_ASZL
- class SurfaceData_EnhancedPBR : SurfaceData_StandardPBR
- {
- AnisotropicSurfaceData anisotropy;
-
- #if ENABLE_TRANSMISSION
- TransmissionSurfaceData transmission;
- #endif
- //! Subsurface scattering parameters
- real subsurfaceScatteringFactor;
- real subsurfaceScatteringQuality;
- real3 scatterDistance;
- }
- #else
- class SurfaceData_EnhancedPBR
- {
- #if ENABLE_CLEAR_COAT
- ClearCoatSurfaceData clearCoat;
- #endif
- AnisotropicSurfaceData anisotropy;
-
- #if ENABLE_TRANSMISSION
- TransmissionSurfaceData transmission;
- #endif
- uint lightingChannels; //!< Lightingchannel of the object
- // ------- BasePbrSurfaceData -------
-
- float3 position; //!< Position in world-space
- real3 normal; //!< Normal in world-space
- real3 vertexNormal; //!< Vertex normal in world-space
- real3 baseColor; //!< Surface base color
- real metallic; //!< Surface metallic property
- real roughnessLinear; //!< Perceptually linear roughness value authored by artists. Must be remapped to roughnessA before use
- real roughnessA; //!< Actual roughness value ( a.k.a. "alpha roughness") to be used in microfacet calculations
- float roughnessA2; //!< Alpha roughness ^ 2 (i.e. roughnessA * roughnessA), used in GGX, cached here for perfromance. Float precision is needed as values can get very close to 0
- real alpha;
- // Increase opacity at grazing angles for surfaces with a low m_opacityAffectsSpecularFactor.
- // For m_opacityAffectsSpecularFactor values close to 0, that indicates a transparent surface
- // like glass, so it becomes less transparent at grazing angles. For m_opacityAffectsSpecularFactor
- // values close to 1.0, that indicates the absence of a surface entirely, so this effect should
- // not apply.
- real opacityAffectsSpecularFactor;
- //! Subsurface scattering parameters
- real subsurfaceScatteringFactor;
- real subsurfaceScatteringQuality;
- real3 scatterDistance;
- //! Surface lighting inputs
- real3 albedo; //!< Albedo color of the non-metallic material, will be multiplied against the diffuse lighting value
- real3 specularF0; //!< Fresnel f0 spectral value of the surface
- real3 emissiveLighting; //!< Emissive lighting
- real diffuseAmbientOcclusion; //!< Diffuse ambient occlusion factor - [0, 1] :: [Dark, Bright]
- real specularOcclusion; //!< Specular occlusion factor - [0, 1] :: [Dark, Bright]
- //! Calculates roughnessA and roughnessA2 after roughness has been set
- void CalculateRoughnessA();
- //! Sets albedo and specularF0 using metallic workflow
- void SetAlbedoAndSpecularF0(real3 baseColor, real specularF0Factor, real metallic);
- real3 GetDiffuseNormal() { return normal; }
- real3 GetSpecularNormal() { return normal; }
- real3 GetDefaultNormal() { return normal; }
- real3 GetVertexNormal() { return vertexNormal; }
- real3 GetSpecularF0() { return specularF0; }
- };
- void SurfaceData_EnhancedPBR::CalculateRoughnessA()
- {
- CalculateRoughnessValues(normal, roughnessLinear, roughnessA, roughnessA2);
- }
- void SurfaceData_EnhancedPBR::SetAlbedoAndSpecularF0(real3 newBaseColor, real specularF0Factor, real newMetallic)
- {
- baseColor = newBaseColor;
- metallic = newMetallic;
- albedo = GetAlbedo(baseColor, metallic);
- specularF0 = CalculateSpecularF0(baseColor, metallic, specularF0Factor);
- }
- #endif
|