Sign in to follow this  

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

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
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();


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

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

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