Sign in to follow this  
Pseudo

TextureShader?

Recommended Posts

I'm trying to get texture shaders working in my managed directx engine but I'm missing something. I would like to use the FillTexture method of TextureLoader but I need a TextureShader. I can create a TextureShader only with a GraphicStream containing the compiled function. I can compile the function using EffectCompiler if I give it an EffectHandle. I dont get how to get an EffectHandle for the function that I want (within and fx file)? There doesn't seem to be any methods of Effect that return an EffectHandle for a function. Any ideas?

Share this post


Link to post
Share on other sites
Yay, I love answering my own question...

It turns out that Effect has about a million UNDOCUMENTED methods and properties. Not that I'm supprised, but I wish they would have at least put empty pages in the help so I would know they were there. Good thing Intellisense came to my aid. For those of you who are interested, Effect has a method called "GetFunction" which does exactly what I needed.

Share this post


Link to post
Share on other sites
Well, just when I thought I had my solution, it turns out I'm still lost.

Now that I have an EffectHandle, I need a GraphicStream of the compiled function. The EffectCompiler seems to be what I need, but there is no overload to create one without an unmanaged ID3DXEffectCompiler.

what I want to do is this:
EffectHandle noiseHandle = effect.GetFunction("GenerateNoise");
EffectCompiler effectCompiler = new EffectCompiler(null);
GraphicStream function = effectCompiler.CompileShader(noiseHandle, "ps_2_0", ShaderFlags.None);
TextureLoader.FillTexture(noiseTexture,new TextureShader(function));

but I cant just put "null" in the constuctor...any ideas? maybe another way of getting the GraphicStream of a function without EffectCompiler?

Share this post


Link to post
Share on other sites
I dont have any experience with managed dx, but this may help you. In ur effect file u can specify a compile target like so:

vertexshader = compile vs_1_1 VS();


Then you can use GetVertexShader() to get a handle to the compiled shader. Maybe there is something similar for MDX? Then again this may not be what u want.

I assume ur trying to fill a texture from another texture (or with some predefined coloring algorithm). So why not just use RenderToTexture and the Sprite interface (if ur rendering a texture to texture) and get ur coloring algorithm going with a pixelshader? I would assume this would be [more] backwards compatible to cards that dont support texture shaders.

Also just on a brief look I see GetFunction() documented in my (old old) mdx docs, so are you sure you've downloaded the updated docs?

Share this post


Link to post
Share on other sites
Actually, i did find it in the docs, but not in the contents list for Effect. I didn't look in BaseEffect yesterday...oops.

the suggestion about compiling it in the effect file doesnt seem to work because I still have no way of getting the GraphicsStream from it. It's not a pixel shader, but rather just a function that the TextureLoader knows how to make into a pixel shader. I suppose I could do it myself, but i wanted to use the built in support if it's possible.

Has anyone successfully used EffectCompiler in MD3D?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this