Jump to content
  • Advertisement
Sign in to follow this  
GoodFun

(Solved) [SlimDX] Setting Shader Resource Variables in DirectX 10

This topic is 3871 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

Hi there, does anyone have some examples on how to set resource variables in shaders using SlimDX and DirectX 10? i.e. extern Texture2D variables and also variables in cbuffers? The only DirectX 10 example that I have only has a simple vertex shader but no textures or cbuffers. Any help is as usual greatly appreciated Thanks Marcel [Edited by - GoodFun on May 13, 2008 6:21:48 PM]

Share this post


Link to post
Share on other sites
Advertisement
Any of the SlimDX developers on that can nudge me in the right direction on this???

Thanks in advance
Marcel

Share this post


Link to post
Share on other sites
Setting effect state is done the same way as the native interface. See here for example. Simply GetEffectVariableBy[Name|Semantic], call AsWhatever() on the resulting EffectVariable to get a WhateverEffectVariable, and then call the appropriate Set() method on that WhateverEffectVariable. Some of the sets and/or gets are missing, but mainly only the uncommon ones. File a bug report if you do happen to find a setter or getter you're missing.

Share this post


Link to post
Share on other sites
jpetrie's suggestion worked... this is the code I've used...

public void SetShaderData(D3D10.Effect shader, D3D10.Device device, Vector4 offset, Vector4 scale)
{
D3D10.EffectVectorVariable texOffset = shader.GetVariableByName("texOffset").AsVector();
D3D10.EffectVectorVariable texScale = shader.GetVariableByName("texScale").AsVector();
D3D10.EffectResourceVariable shaderTexture = shader.GetVariableByName("dataTexture").AsResource();

texOffset.Set(offset);
texScale.Set(scale);

D3D10.ShaderResourceView textureView = new D3D10.ShaderResourceView(device, _texture);
shaderTexture.SetResource(textureView);
}

I've also added overloads to set int and float arrays, I'll post a bug report with the code I've added.

Thanks for your help Josh

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!