Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Program Announcements / ID3DXEffect Wrapper Plugin for DBPro

Author
Message
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 5th Mar 2017 18:25 Edited at: 8th Aug 2017 18:13
Notice: This plugin has been discontinued and is no longer receiving updates. Please direct all comments and questions to the new jGfx thread.

Hi everyone, During development of a recent project I found the need for a faster alternative to Dark Shader's Set Effect Constant Vector Element command. Although use of this plugin is a bit clunkier than the existing solutions it does come with a few advantages:

1) Does not require referencing constants by name each time they are manipulated
2) Set vector and matrix constants without needing to use DBPro's math resources
3) Can retrieve shader constant values
4) Matrix Array Support

The download comes with a few bare-bones examples to demonstrate basic usage, but because the plugin is merely a wrapper (and I'm not sure how many people will actually use this) I didn't bother to write any help files. You can find microsoft's documentation at ID3DXBaseEffect interface and ID3DXEffect interface.

Update 2/7/2017:
-Included two new examples showing usage of this plugin in conjunction with MatBit's eXtendet Rotation plugin.


Update 2/18/2017:
-Updated Poke Vector4 to be slightly faster
-Added Poke Vector2/Poke Vector3 commands
-Added examples demonstrating batch rendering of up to 80 dynamic objects using vector arrays (with and without the eXtendet Rotation plugin)

Update 6/3/2017:
-Added 4 new commands: GetParameterBySemantic, GetParameterElement, GetValue, and SetValue

Update 7/28/2017:
-Added 5 new commands: ID3DXEffect_SetBoolVal, ID3DXEffect_SetFloatVal, ID3DXEffect_SetIntVal, ID3DXEffect_SetVectorVal, ID3DXEffect_SetMatrixVal for setting constants by value


Command List (44 total):



This plugin only provides wrapper commands for members I thought people might find useful. If I've missed anything important let me know.

Attachments

Login to view attachments
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 7th Mar 2017 00:07
I've subscribed to this thread and downloaded a copy to play around with later. Thanks for sharing.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 7th Mar 2017 21:17
You're welcome, let me know if you find any issues or have suggestions for improvement.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 7th Mar 2017 23:47
Updated download in first post; corrected error in the matrix pointer array example, two new examples using MatBit's eXtendet Rotation plugin as a replacement for dbpro's native vector/matrix commands.
Kuper
16
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 15th Mar 2017 23:18
Will it be faster than darkShader's when setting effect Vector Element?
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 16th Mar 2017 03:12
Yes, on my machine it is x7-x8 faster. This plugin helps to cut down on the work which is needlessly repeated each time the "set effect constant" commands are called (less string usage, avoids dbp's math resources, reuses effect constant handles).
Kuper
16
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 16th Mar 2017 21:32 Edited at: 16th Mar 2017 21:33
Test it on Win7 and DBProEx 1.0.0.8. Works fine.
Also I get boost about 50% ( dark shader fps 223 vs fps 376 ID3DX )
Maybe I did something wrong?

revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 17th Mar 2017 03:02 Edited at: 19th Mar 2017 16:01
Hi Kuper, thanks for testing. Remove all of those rnd(255)/255.0, they are effecting the program's speed more than anything. Also, you should not use the framerate counter to test the speed of specific commands; a program is always doing more than just calling the command you wish to test, and so it is not possible to see the total difference in command speed through FPS alone.

Kuper
16
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 17th Mar 2017 13:22
Thanks revenant chaos!
Nice snippet
I think only MatrixUtils have such hiresolution timer? DBPro's timer() and perftimer() doesn't provide such accurate results
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 17th Mar 2017 13:41 Edited at: 17th Mar 2017 14:06
You're welcome, thanks again for testing. Could I ask how much of a speed difference you get with the revised code?
Quote: "I think only MatrixUtils have such hiresolution timer?"
Yeah sorry about that; I think PerfTimer() should be more than accurate enough to replace the calls to HiTimer().


[Edit] Updated the above code snippet to use PerfTimer(), and modified the darkshader test loop to be a bit more realistic (corrected a silly error...)
Kuper
16
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 17th Mar 2017 15:00
I've tested with PerfTimer() already ( cause I try to use as less plugins as i can ) and it shows much lower speed difference
between DarkShader and D3DXEffect.( about 6 times )
Matrix utils timer shows about 10 times difference.
Seems like HiTimer() is best solution to get perfomance statistic of your code


revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 17th Mar 2017 15:26
Thanks man
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 18th Mar 2017 09:10
Great work, thanks for sharing!
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 18th Mar 2017 19:15
Thanks and you're welcome Rudolpho!

Uploaded new version, see first post for details.
Bored of the Rings
User Banned
Posted: 25th Mar 2017 07:42 Edited at: 25th Mar 2017 07:46
[oops wrong post, sorry]
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Kuper
16
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 5th Apr 2017 14:06
How to use "AnimBone_SetPosition" command"?
I'l try to use it for inverse kinematic like this:
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 7th Apr 2017 02:27 Edited at: 7th Apr 2017 02:36
Hi Kuper, Wrong thread
The AnimBone_SetPosition command is used to define a bone's position (or position offset) within it's parent's local coordinate space. If any animations are being played onto the bone, manually defined rotation/position/scale will be overwritten when AnimObject_Update is called. This is not true for bone rotation/position/scale offsets. Much like DBPro's offset limb, the effects of this command are typically not desirable when used in conjunction with multi-weighted geometry.

To achieve inverse kinematics like you show in the picture, you would need to apply rotation offsets to the bones which lead from the pelvis down to each foot.

It should be noted that jGpuSkin was written with forward kinematics in mind, with speed being it's main concern. I do not have any plans to implement IK in the future.
Kuper
16
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 7th Apr 2017 12:05
Sorry wrong thread indeed!!
Move question to right one
Kuper
16
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 2nd Jun 2017 20:30
Is it possible to set not all float4 array elements at once but only variable[1] for example?
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 4th Jun 2017 04:13
Updated first post with a new version.

Hi Kuper, the new version I've just uploaded contains the command you are looking for: ID3DXEffect_GetParameterElement(). Example:
Kuper
16
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 4th Jun 2017 12:45
@revenant chaos
Wow you just read my mind
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 5th Jun 2017 03:50
Nope, realized it was missing because you asked.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 29th Jul 2017 01:45
Updated first post with a new version, adds commands for setting boolean, float, integer, vector and matrix constants by value rather than using pointers.
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 31st Jul 2017 13:42
Great stuff, thank you for sharing!
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 7th Aug 2017 08:53
You're welcome Chris, I hope everyone finds it useful but I'm here to announce this plugin will not be receiving any farther updates. It's functionality has been implemented into a soon-to-be released plugin which combines my ID3DXEffect and MRT tpcs; along with new commands for dynamic cubemapping and gpu-accelerated geometry instancing. The new plugin will be entitled jGfx, and I'm hoping to get it released within the next few days.

Login to post a reply

Server time is: 2024-03-29 07:24:04
Your offset time is: 2024-03-29 07:24:04