how to pass a float4 to hlsl using vb

R

Richy

Hi,

This is a Direct3D-related question but I am posting it in here as it
is more VB-specific.

I have an effect file that I am trying to set the values for. For
example:

fx.SetValue("matView", _viewMatrix)
fx.SetValue("matViewProjection", _projectionMatrix)
fx.SetValue("fSpecularPower", 25)
fx.SetValue("base_Tex", t._texture(0))


That all works fine, but I cannot for the life of me get a float3 or
float4 across, example:

Dim diffuse(3) As Single
diffuse(0) = 0 : diffuse(1) = 1 : diffuse(2) = 0 : diffuse(3) = 0
fx.SetValue("fvDiffuse", diffuse)

I've also tried setting diffuse to an upperbound of 4.

This all fails with the meaningless "Error in the application". I
thought a Float4 was simply an array of four floating point (type
Single) numbers? I have the same issue with a Float3, I've tried all
I
can think of to pass the information over but no luck. Here is how
fvDiffuse is set up in the .fx file:

float4 fvDiffuse
<
string UIName = "fvDiffuse";
string UIWidget = "Color";
bool UIVisible = true;
= float4( 0.89, 0.89, 0.89, 1.00 );

Isn't this just an array of four values of type Single?

Thanks in advance,

Richy
 
A

Armin Zingler

Richy said:
Hi,

This is a Direct3D-related question but I am posting it in here as
it is more VB-specific.

I have an effect file that I am trying to set the values for. For
example:

fx.SetValue("matView", _viewMatrix)
fx.SetValue("matViewProjection", _projectionMatrix)
fx.SetValue("fSpecularPower", 25)
fx.SetValue("base_Tex", t._texture(0))

I looked at the MDX documentation but I don't find a single method called
SetValue that takes a string as the first argument. What is fx? If it's an
Effect then the first arg is always an EffectHandle, not a String. Maybe I
missed something.

That all works fine, but I cannot for the life of me get a float3 or
float4 across, example:

Dim diffuse(3) As Single
diffuse(0) = 0 : diffuse(1) = 1 : diffuse(2) = 0 : diffuse(3) = 0
fx.SetValue("fvDiffuse", diffuse)

I've also tried setting diffuse to an upperbound of 4.

This all fails with the meaningless "Error in the application".

In the MDX group the default questions are:
Debug runtime installed? Unmanaged debugging enabled? What does the debug
output say?

I you won't get a solution here, there is also
m.p.win32.programmer.directx.managed.
 
R

Richy

I looked at the MDX documentation but I don't find a single method called
SetValue that takes a string as the first argument. What is fx? If it's an
Effect then the first arg is always an EffectHandle, not a String. Maybe I
missed something.

Weird I know, the doco says the first parameter is of type
Microsoft.DirectX.Direct3D.EffectHandle, but one can supply the name
of the property as a string and it works fine.
In the MDX group the default questions are:
Debug runtime installed? Unmanaged debugging enabled? What does the debug
output say?

I you won't get a solution here, there is also
m.p.win32.programmer.directx.managed.

Yeah I tried that but they suggested a VB group as it's more related
to VB, as in it is the data structure itself and how it can be passed
to the subroutine. One of the parameter types (for the second
parameter) is a Single() array but that does not work for me, I
thought somebody might be able to help with this. I've created a
structure containing three singles (which should be the equivalent of
a FLOAT3) but it cannot be passed across.

Thanks anyway :)
 
A

Armin Zingler

Richy said:
Weird I know, the doco says the first parameter is of type
Microsoft.DirectX.Direct3D.EffectHandle, but one can supply the name
of the property as a string and it works fine.

Strange. I can not even compile it.
Yeah I tried that

In the group mentioned? I only see one posting in the other (unmanaged)
group.
but they suggested a VB group as it's more related
to VB, as in it is the data structure itself and how it can be
passed to the subroutine. One of the parameter types (for the second
parameter) is a Single() array but that does not work for me, I
thought somebody might be able to help with this. I've created a
structure containing three singles (which should be the equivalent
of a FLOAT3) but it cannot be passed across.

Thanks anyway :)

You said you get an "error in application". Is this a runtime error? And
again: Debug runtime installed? Unmanaged debugging enabled? What does the
debug output say?


Armin
 
R

Richy

In the group mentioned? I only see one posting in the other (unmanaged)
group.

Oops I did it to the .graphics not the .managed, I'll try the .managed
You said you get an "error in application". Is this a runtime error? And
again: Debug runtime installed? Unmanaged debugging enabled? What does the
debug output say?

Armin

I am using DirectX version .Net 1.0.900.0 but I don't think I am using
the Debug run-time, how can I tell and if I am not where do I get it
from? It is all included in the SDK I would have downloaded to get
DirectX?

The "error in the application" is a run-time error [5]

Thanks,

Richy
 
A

Armin Zingler

Richy said:
Oops I did it to the .graphics not the .managed, I'll try the
.managed


I am using DirectX version .Net 1.0.900.0

Of which file is this the version? I have several versions installed (over
the time) but the oldest I have is 1.0.2902.0. I suggest to download the
latest SDK if you haven't already. (be aware that un-/reinstalling resets
your customized IDE settings like toolbars and menus :-(
but I don't think I am
using the Debug run-time, how can I tell and if I am not where do I
get it from? It is all included in the SDK I would have downloaded
to get DirectX?

The "error in the application" is a run-time error [5]


If you install the SDK, it integrates in the IDE. In menu
Tools->Options->Debugging->DirectX you can switch between the Debug and
Retail version. You can do this also either in the control panel
("DirectX"), or, in the newest version (Dec 2006), it's in the start
menu -> DirectX SDK -> Utilities -> DirectX Control panel.

In addition, you must enable "unmanaged debugging" in the project
properties. (configuration properties -> debugging: [X] unmanaged debugging)

More see the DirectX Documentation: DirectX Software Development Kit ->
DirectX SDK Programming Guide -> Programming DirectX with C/C++ -> Debugging
DirectX Applications

(the unmanaged documentation is no real help because it's totally incomplete
(and will never be completed))


If you enabled the above, you will get additional information in the output
window in the IDE if a directX error occurs. Don't know if this is one, but
you can this first.

More about it in the MDX group. :)


Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top