-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathForwardBaseRenderPass.cpp
More file actions
66 lines (62 loc) · 1.94 KB
/
Copy pathForwardBaseRenderPass.cpp
File metadata and controls
66 lines (62 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "WorldRenderPass.h"
#include "Material.h"
#include "Mesh.h"
#include "CoreLib/LibIO.h"
#include "Spire/Spire.h"
using namespace CoreLib;
using namespace CoreLib::IO;
namespace GameEngine
{
class ForwardBaseRenderPass : public WorldRenderPass
{
private:
const char * shaderSrc = R"(
template shader ForwardBase(passParams : ForwardBasePassParams,
lightingModule,
geometryModule : IMaterialGeometry,
materialModule : IMaterialPattern,
animationModule,
vertexAttribModule) targets StandardPipeline
{
public using vertexAttribModule;
public using passParams;
public using animationModule;
public using TangentSpaceTransform;
public using geometryModule;
public using VertexTransform;
public using materialModule;
vec3 lightParam = vec3(roughness, metallic, specular);
using lighting = lightingModule(TangentSpaceToWorldSpace(vec3(normal.x, -normal.y, normal.z)));
public out @Fragment vec4 outputColor
{
if (opacity < 0.01f) discard;
return vec4(lighting.result, opacity);
}
};
)";
public:
const char * GetShaderSource() override
{
return shaderSrc;
}
RenderTargetLayout * CreateRenderTargetLayout() override
{
return hwRenderer->CreateRenderTargetLayout(MakeArray(
AttachmentLayout(TextureUsage::ColorAttachment, StorageFormat::RGBA_F16),
AttachmentLayout(TextureUsage::DepthAttachment, DepthBufferFormat)).GetArrayView());
}
virtual void SetPipelineStates(FixedFunctionPipelineStates & state)
{
state.BlendMode = BlendMode::AlphaBlend;
state.DepthCompareFunc = CompareFunc::LessEqual;
}
virtual char * GetName() override
{
return "ForwardBase";
}
};
WorldRenderPass * CreateForwardBaseRenderPass()
{
return new ForwardBaseRenderPass();
}
}