Dynamic shader linkage : class from other shader/file

Started by
-1 comments, last by Juliean 10 years, 7 months ago

Hello,

in a thread a while ago, I asked about a way of dynamically altering the implementation of shader: shader "plugin" system. I was told to use dynamic shader linkage, and since I've now seperated all my modules into dll plugins, I've finally decided to implement it. I expected it to work like this:

// file Ambient.fx


interface IAmbient
{
	float AmbientTerm(float2 vTex);
};

IAmbient iAmbient;

float4 mainPS(VS_OUTPUT i) : SV_Target0
{
	return iAmbient.AmbientTerm(i.vTex0);
};

// file SSAO.fx


class SSAO: IAmbient
{
	float AmbientTerm(float2 vTex)
        {
               // calc & return... ssao term
        }
};

SSAO cSSAO;

Then I thought I could just get the SSAO-declaration using ID3D11ClassLinkage::GetClassInstance and set it as input to the PSSetShader()-method when applying the ambient pixel shader.

However, I get

- an error when I don't at least derive one class from the interface in the very shader that declares it.

- a 0 as return value when using ID3D11ShaderReflection::GetNumInterfaceSlots (appearently you need to derive at least two different classes from he interface in the same shader file, for the interface to be usable).

This leads me to belive that what I want to achieve is not double in the way I tried. Does anyone know if there is any way to "inject" an interface implementation after the shader has been compiled, without needing to have to declare two classes from the interface myself in the same shader?

This topic is closed to new replies.

Advertisement