Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split Materialpipeline - shader code into two files #18549

Open
wants to merge 4 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@

//////////////////////////////////////////////////////////////////////////////////////////////////

#ifdef MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#include MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////

#include <viewsrg.srgi>
#include <scenesrg.srgi>
#include <Atom/Features/Pipeline/Forward/ForwardPassVertexData.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassPipelineCallbacks.azsli>

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH

//////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@

//////////////////////////////////////////////////////////////////////////////////////////////////

#ifdef MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#include MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////

#include <viewsrg.srgi>
#include <scenesrg.srgi>
#include <Atom/Features/Pipeline/Forward/ForwardPassVertexData.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassPipelineCallbacks.azsli>

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH

//////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -28,7 +41,11 @@ struct PsOutput

PsOutput PixelShader(VsOutput IN, bool isFrontFace : SV_IsFrontFace)
{
PixelGeometryData geoData = EvaluatePixelGeometry(IN, isFrontFace);
// ------- Reconstruct the Instance-Id --------
VsSystemValues SV;
SV.m_instanceId = IN.m_instanceId;

PixelGeometryData geoData = EvaluatePixelGeometry(IN, SV, isFrontFace);

// Pixel clipping can be done here
EvaluateSurface(IN, geoData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,28 @@
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/


#define MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE 0 // Well, it does have a pixel stage, but not one that can be customized.
#define MATERIALPIPELINE_USES_PREV_VERTEX_POSITION 1

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH
#ifdef MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#include MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////

#include <scenesrg.srgi>
#include <viewsrg.srgi>
#include <scenesrg.srgi>
#include <Atom/Features/Pipeline/Forward/ForwardPassVertexData.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassPipelineCallbacks.azsli>

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH

//////////////////////////////////////////////////////////////////////////////////////////////////

struct PsOutput
{
Expand All @@ -35,12 +44,18 @@ VsOutput VertexShader(VsInput IN, uint instanceId : SV_InstanceID)
PsOutput PixelShader(VsOutput IN)
{
PsOutput OUT;

// re-create the System-Values for the Pixel
VsSystemValues SV;
SV.m_instanceId = IN.m_instanceId;

// Current clip position
float4 clipPos = mul(ViewSrg::m_viewProjectionMatrix, float4(IN.m_worldPos, 1.0));
float4x4 viewProjectionMatrix = GetViewProjectionMatrix(SV);
float4 clipPos = mul(viewProjectionMatrix, float4(IN.worldPosition, 1.0));

float4x4 viewProjectionPrevMatrix = GetViewProjectionPrevMatrix(SV);
// Reprojected last frame's clip position, for skinned mesh it also implies last key frame
float4 clipPosPrev = mul(ViewSrg::m_viewProjectionPrevMatrix, float4(IN.m_worldPosPrev, 1.0));
float4 clipPosPrev = mul(viewProjectionPrevMatrix, float4(IN.worldPosPrev, 1.0));

float2 motion = (clipPos.xy / clipPos.w - clipPosPrev.xy / clipPosPrev.w) * 0.5;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ VsOutput VertexShader(VsInput IN, uint instanceId : SV_InstanceID)

ForwardPassOutput PixelShader(VsOutput IN, bool isFrontFace : SV_IsFrontFace)
{
// ------- Reconstruct the Instance-Id --------
VsSystemValues SV;
SV.m_instanceId = IN.m_instanceId;

// ------- Geometry -> Surface -> Lighting -------

PixelGeometryData geoData = EvaluatePixelGeometry(IN, isFrontFace);
PixelGeometryData geoData = EvaluatePixelGeometry(IN, SV, isFrontFace);

Surface surface = EvaluateSurface(IN, geoData);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,23 @@

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH
#ifdef MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#include MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////

#include <viewsrg.srgi>
#include <scenesrg.srgi>
#include <Atom/Features/Pipeline/Forward/ForwardPassSrg.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassVertexData.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassPipelineCallbacks.azsli>

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH

//////////////////////////////////////////////////////////////////////////////////////////////////

#include "../../../Shaders/Materials/BasePBR/BasePBR_LightingData.azsli"
#include "../../../Shaders/Materials/BasePBR/BasePBR_LightingBrdf.azsli"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,23 @@

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH
#ifdef MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#include MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////

#include <viewsrg.srgi>
#include <scenesrg.srgi>
#include <Atom/Features/Pipeline/Forward/ForwardPassSrg.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassVertexData.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassPipelineCallbacks.azsli>

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH

//////////////////////////////////////////////////////////////////////////////////////////////////

// TODO(MaterialPipeline): I don't like how this file #includes something from BasePBR. I'd rather it include a file
// called StandardPBR_LightingData.azsli which just #includes the BasePBR file. Otherwise this looks suspicious like
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,23 @@

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH
#ifdef MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#include MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////

#include <viewsrg.srgi>
#include <scenesrg.srgi>
#include <Atom/Features/Pipeline/Forward/ForwardPassSrg.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassVertexData.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassPipelineCallbacks.azsli>

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH

//////////////////////////////////////////////////////////////////////////////////////////////////

// TODO(MaterialPipeline): I don't like how this file #includes something from BasePBR. I'd rather it include a file
// called StandardPBR_LightingData.azsli which just #includes the BasePBR file. Otherwise this looks suspicious like
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ VsOutput VertexShader(VsInput IN, uint instanceId : SV_InstanceID)
#endif
ForwardPassOutput PixelShader(VsOutput IN, bool isFrontFace : SV_IsFrontFace)
{
// ------- Reconstruct the Instance-Id --------
VsSystemValues SV;
SV.m_instanceId = IN.m_instanceId;

// ------- Geometry -> Surface -> Lighting -------

PixelGeometryData geoData = EvaluatePixelGeometry(IN, isFrontFace);
PixelGeometryData geoData = EvaluatePixelGeometry(IN, SV, isFrontFace);

Surface surface = EvaluateSurface(IN, geoData);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,24 @@

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH
#ifdef MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#include MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////

#include <viewsrg.srgi>
#include <scenesrg.srgi>
#include <Atom/Features/Pipeline/Forward/ForwardPassSrg.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassVertexData.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassPipelineCallbacks.azsli>


//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH

//////////////////////////////////////////////////////////////////////////////////////////////////

// TODO(MaterialPipeline): I don't like how this file #includes something from BasePBR. I'd rather it include a file
// called StandardPBR_LightingData.azsli which just #includes the BasePBR file. Otherwise this looks suspicious like
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ VsOutput VertexShader(VsInput IN, uint instanceId : SV_InstanceID)
VsSystemValues SV;
SV.m_instanceId = instanceId;
VsOutput OUT = EvaluateVertexGeometry(IN, SV);
OUT.m_instanceId = instanceId;
return OUT;
}

Expand All @@ -44,9 +45,13 @@ float GetSubsurfaceScatteringFactorAndQuality(Surface surface)

ForwardPassOutput PixelShader(VsOutput IN, bool isFrontFace : SV_IsFrontFace)
{
// ------- Reconstruct the Instance-Id --------
VsSystemValues SV;
SV.m_instanceId = IN.m_instanceId;

// ------- Geometry -> Surface -> Lighting -------

PixelGeometryData geoData = EvaluatePixelGeometry(IN, isFrontFace);
PixelGeometryData geoData = EvaluatePixelGeometry(IN, SV, isFrontFace);

Surface surface = EvaluateSurface(IN, geoData);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,24 @@

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH
#ifdef MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#include MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////

#include <viewsrg.srgi>
#include <scenesrg.srgi>
#include <Atom/Features/Pipeline/Forward/ForwardPassSrg.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassVertexData.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassPipelineCallbacks.azsli>

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH

//////////////////////////////////////////////////////////////////////////////////////////////////


#include "../../../Shaders/Materials/BasePBR/BasePBR_LightingData.azsli"
#include "../../../Shaders/Materials/BasePBR/BasePBR_LightingBrdf.azsli"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,23 @@

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH
#ifdef MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#include MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////

#include <viewsrg.srgi>
#include <scenesrg.srgi>
#include <Atom/Features/Pipeline/Forward/ForwardPassSrg.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassVertexData.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassPipelineCallbacks.azsli>

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH

//////////////////////////////////////////////////////////////////////////////////////////////////

// TODO(MaterialPipeline): I don't like how this file #includes something from BasePBR. I'd rather it include a file
// called StandardPBR_LightingData.azsli which just #includes the BasePBR file. Otherwise this looks suspicious like
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,23 @@

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH
#ifdef MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#include MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////

#include <viewsrg.srgi>
#include <scenesrg.srgi>
#include <Atom/Features/Pipeline/Forward/ForwardPassSrg.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassVertexData.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassPipelineCallbacks.azsli>

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH

//////////////////////////////////////////////////////////////////////////////////////////////////

// TODO(MaterialPipeline): I don't like how this file #includes something from BasePBR. I'd rather it include a file
// called StandardPBR_LightingData.azsli which just #includes the BasePBR file. Otherwise this looks suspicious like
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,23 @@

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH
#ifdef MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#include MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////

#include <viewsrg.srgi>
#include <scenesrg.srgi>
#include <Atom/Features/Pipeline/Forward/ForwardPassSrg.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassVertexData.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassPipelineCallbacks.azsli>

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH

//////////////////////////////////////////////////////////////////////////////////////////////////

// TODO(MaterialPipeline): I don't like how this file #includes something from BasePBR. I'd rather it include a file
// called StandardPBR_LightingData.azsli which just #includes the BasePBR file. Otherwise this looks suspicious like
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,23 @@

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH
#ifdef MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#include MATERIAL_TYPE_DEFINES_AZSLI_FILE_PATH
#endif

//////////////////////////////////////////////////////////////////////////////////////////////////

#include <viewsrg.srgi>
#include <scenesrg.srgi>
#include <Atom/Features/Pipeline/Forward/ForwardPassSrg.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassVertexData.azsli>
#include <Atom/Features/Pipeline/Forward/ForwardPassPipelineCallbacks.azsli>

//////////////////////////////////////////////////////////////////////////////////////////////////

#include MATERIAL_TYPE_AZSLI_FILE_PATH

//////////////////////////////////////////////////////////////////////////////////////////////////

// TODO(MaterialPipeline): I don't like how this file #includes something from BasePBR. I'd rather it include a file
// called StandardPBR_LightingData.azsli which just #includes the BasePBR file. Otherwise this looks suspicious like
Expand Down
Loading