Hello,
recently, I've been working on making my engine more modular, by splitting up most high-level/shader implementations of things like lighting, shadows, HDR, etc... into modules, that can (theoretically) easily be pluged/unplugged, and should later even be loaded from DLLs via a plugin manager rather than in code. Its quite a way there, but right now, I've got one big problem: What am I supposed to do with the shaders? For example, if this is my lighting shader:
#include "../../Base/Effects/Vertex.afx"
cbuffer instance : register(b2)
{
float4 cAmbientColor;
};
sampler InputSampler : register(s0);
Texture2D <float4> Material : register(t0);
float4 mainPS(VS_OUTPUT i) : SV_Target0
{
float4 vDiffuseMaterial;
vDiffuseMaterial.rgb = Material.Sample(InputSampler, i.vTex0).rgb;
vDiffuseMaterial.rgb *= cAmbientColor.rgb;
vDiffuseMaterial.rgb *= cAmbientColor.a;
vDiffuseMaterial.a = 1.0;
return vDiffuseMaterial;
}; Say I want to make an SSAO-plugin, which isn't really that hard. Effects, textures etc.. are being loaded from a resource-config file, however, how am I supposed to apply the rendered ssao output to the ambient shader? I basically need to insert this line:
vDiffuseMaterial.rgb *= 1.0-SSAO.Sample(InputSampler, i.vTex0).r;
in the middle, alongside with the definition of the SSAO texture.
Whats a viable way to do so? I really don't have any clue how to do so, without simply shipping a seperate SSAO-enabled ambient lighting shader with the SSAO-plugin. Is there any other way? I'd prefer if it potentially could work with any lighting implementation that follows certain rules, but even if there is a way to enchance just that special shader offered by the DeferredLighting-plugin I have, I'd still be very glad. Ideas?