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.

DarkBASIC Professional Discussion / Limb Texture Blending Finally :)

Author
Message
Lost in Thought
22
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 23rd Aug 2010 20:58 Edited at: 23rd Aug 2010 23:22
Just got back around to programming again and found that Lee added a VERY important functionality to the set blend mapping on command!

I have tried for years to do texture blending on an object with multiple limbs that have different textures on different limbs.

Green Gandalf gave me my first option. A shader that simply uses the images already on the mesh for blending.
Pro's: Simple and works on relatively any system
Con's: Slower than the built in set blend mapping command by apx 15%

Shader file attached


IanM gave me the second option. His matrix utilities plugin set has a set limb texture blend mode that works well.
Pro's: Same speed as the set blendmapping command
Con's: Can't be used with DGDK or DGDK.net



And now Lee has given me the best option. The new functionality.
Pro's: Very Fast and will be available to DGDK and DGDK.net if it isn't already
Con's: Confusing (for me anyway) to use. So I got some help from Green Gandalf on it



Green Gandalf's instructions

1. All the familiar parameters should be the same as before or obvious.
2. Set Arg1 to CURRENT, i.e. 1
3. Set Arg2 to TEXTURE, i.e. 2
4. Set Arg0 to -1, i.e. not used
5. Set ArgResult to CURRENT, i.e. 1 again. (In other words the result of the blending operation becomes the new CURRENT texture.)

Works perfectly! Thanks again Green Gandalf

[edit] Forgot to mention that all of those use the modulate 2x blend mode ... even the shader.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Aug 2010 21:30
Thanks for the credit. One thing puzzles me - where did you find the full syntax for the current version of the set blend mapping on command?

I believe it was introduced in U7.3 but can't find any mention of the new syntax in either the Upgrade txt file or the DBPro Help file.

The odd thing is that I'm sure I've seen it somewhere before(although if I have I'd not noticed that Lee had introduced support for limbs at the same time so I'm glad you've spotted that ). Perhaps it's buried in an email from Lee. I'll have a look and post back if I find anything useful.
Lost in Thought
22
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 23rd Aug 2010 21:42
http://forum.thegamecreators.com/?m=forum_view&t=29734&b=15

The release details post by IanM in the bug reports forum. I find any and all info on the updates I want there It is mentioned in the U7.3 and U7.4 sections. More thoroughly in the 7.4 one.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Aug 2010 21:55
Ah! I hadn't realised the extra limb parameter was added in U7.4. I only checked U7.3.

Actually, to be consistent with DX9 terminology, I think the arguments should be listed as Arg1, Arg2 and Arg3 rather than the somewhat confusing Arg1, Arg2 and Arg0. One of those rare typos, I guess.

Certainly an incredibly useful command now.
Lost in Thought
22
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 23rd Aug 2010 23:14
He actually went back and added it in U7.4 cause I asked him about it again LOL. I looked back in the email he sent me and in the U7.4 update and for some reason he used arg0 instaed of arg3 in both 0_o I also edited my first post to show the full syntax as I forgot to put it

DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 23rd Aug 2010 23:25
WOOSH! What was that!? I think it was your conversation going over my head! No idea what you guys are talking about, but it sounds suitably complicated and technical! Probably damn useful too if you understand it

http://s6.bitefight.org/c.php?uid=103081
Lost in Thought
22
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 23rd Aug 2010 23:53 Edited at: 23rd Aug 2010 23:58
It is very usefull and the only thing that puzzles me is why it's not in the help files at all as far as I can tell!

It's actually not so complicated once you use it ... not for what I'm using it for anyway. I am using it in the open source .3dw importer I am working on. I am using it to do the lightmapping on the level. To take the main texture and lightmap texture and blend them together for the lightmapping effect. This is done by an effect called modulation (mode 4 in that command) usually, but I had to use modulation 2x (mode 5) to make it brighter to match 3dws's lighting.

I'm late for work now, but I can post a full example showing it later if you want.

[edit] Here is a slightly modified version of the code Green Gandalf sent me for the matrix utilities command changed to use this.



Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Aug 2010 01:10
You don't need to texture stage 1 since your blend mapping commands do the required calculations anyway so your snippet can be simplified a bit to:

Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 24th Aug 2010 05:27
Wait, could someone explain what the whole Arg1,Arg2,Arg3,ArgResult are.

My computer surpasses all the technologies of the day. What computer do I have?

Lost in Thought
22
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 24th Aug 2010 13:05 Edited at: 24th Aug 2010 13:32
Thanks GG I missed that

@ Madscientist ... that is a very complex answer to fully explain. The simple version is that different blending modes need arguments passed to them. You'll have to do some research into directx blending I believe to know which needs what. Or ask GG like I did LOL. Modulate and modulate 2x used for lightmapping needs arg1, arg2, and argresult. It doesn't need the third arg (arg0 which is supposed to be arg3) so you just set it to -1. An explaination of the possible values to use for the arg parameters can be found in the lerping textures example in your Dark Basic Professional\Projects\Snippets\LerpingTextures folder at the very bottom of the code. In our case we need to use 1 for arg1. One tells it to use the current stage destination register to start. We need to use 2 for arg2 to tell it to use the texture data specified for the modulation. And we need to use 1 for argresult to tell it to put the result in the current stage destination register. This is how I see it and may not be totally accurate way of explaining it.

Possible arg values from the code snippet:


GG may have more info or a better/ more technical explaination

[edit] More info on blending can be found at these 2 links:

http://forum.thegamecreators.com/?m=forum_view&t=153935&b=1

http://msdn.microsoft.com/en-us/library/bb206241(v=VS.85).aspx

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Aug 2010 14:03
Quote: "@ Madscientist ... that is a very complex answer to fully explain."


I agree.

You might like to try the attached demo and read the comments in the dba file. It illustrates 5 uses of blend mapping (but only describes the last 4 ).

Let me know if anything isn't clear and I'll edit the comments.

(Just noticed I didn't explain that "-1" is used when an argument isn't needed. )
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 24th Aug 2010 16:45
I'm confused. Are the arg values just for copying and storing the texture data for other blend modes to use?
Well then for basic normal mapping would this work?


My computer surpasses all the technologies of the day. What computer do I have?

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Aug 2010 17:36
Quote: "Are the arg values just for copying and storing the texture data for other blend modes to use?"


No, they specify what textures to use in the cuurrent blending stage - the different values refer to the various textures maintained behind the scenes by DirectX. These are the values given by Lee in his LerpingTextures snippet:



The only ones I'm familiar with are 0, 1, 2, 4 and 5.

The parameter ArgResult is the one which allows you to specify where to store the result - in TEMP or CURRENT. The usual syntax just uses CURRENT behind the scenes.

Quote: "Well then for basic normal mapping would this work?"


Not quite - it "works" but probably isn't what you want. I believe you need blend mode 24, i.e. DOTPRODUCT3. You also need to reverse the order like this:



See attached demo. The demo only uses limb 0 but any limb could be handled this way. It's "cheap" normal mapping and doesn't seem to react to the light direction consistently - but it passes a quick glance.

KisTech posted another demo for this some time back including specular reflection.

Login to post a reply

Server time is: 2026-07-23 12:10:32
Your offset time is: 2026-07-23 12:10:32