12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- /*
- * 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
- #include <Atom/Features/Pipeline/Forward/ForwardPassOutput.azsli>
- #include <Atom/Features/PostProcessing/Tonemap.azsli>
- #include <Atom/Features/ColorManagement/TransformColor.azsli>
- // --- Vertex Shader ---
- VsOutput VertexShader(VsInput IN, uint instanceId : SV_InstanceID)
- {
- VsSystemValues SV;
- SV.m_instanceId = instanceId;
- VsOutput OUT = EvaluateVertexGeometry(IN, SV, GetMaterialParameters());
- return OUT;
- }
- // --- Pixel Shader ---
- #if FORCE_EARLY_DEPTH_STENCIL
- [earlydepthstencil]
- #endif
- ForwardPassOutput PixelShader(VsOutput IN, bool isFrontFace : SV_IsFrontFace)
- {
- float3 views[MAX_SHADING_VIEWS];
- views[0] = ViewSrg::m_worldPosition.xyz; // Assume one view for forward pass for now
- // ------- Geometry -> Surface -> Lighting -------
- PixelGeometryData geoData = EvaluatePixelGeometry(IN, isFrontFace, GetMaterialParameters());
- Surface surface = EvaluateSurface(IN, geoData, GetMaterialParameters());
- LightingData lightingData = EvaluateLighting(surface, IN.position, views);
- // ------- Output -------
- ForwardPassOutput OUT;
- real3 color = lightingData.diffuseLighting.rgb + lightingData.emissiveLighting.rgb;
- for(uint i = 0; i < GET_SHADING_VIEW_COUNT; ++i)
- {
- color += lightingData.specularLighting[i];
- }
- #if ENABLE_MERGE_FILMIC_TONEMAP
- // Apply manual exposure compensation
- color = ApplyManualExposure(color, real(ViewSrg::GetExposureValueCompensation()));
-
- //Convert to linearsrg space as we are in acescg space and we will not be applying aces tonemap
- color = AcesCg_To_LinearSrgb(color);
- // We could add other forms of tonemapping in future via shader options.
- color = TonemapFilmic(color);
- #endif
- OUT.m_color.rgb = color;
- OUT.m_color.a = 1.0;
- #if OUTPUT_DEPTH
- OUT.m_depth = IN.position.z;
- #endif
- return OUT;
- }
|