Jump to content
  • Advertisement
Sign in to follow this  

Dynamic shader linkage : class from other shader/file

This topic is 2126 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



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


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?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!