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.

Newcomers DBPro Corner / Magic FVF code to fix shader woes

Author
Message
Cagedrei
15
Years of Service
User Offline
Joined: 18th Mar 2009
Location:
Posted: 19th Apr 2009 23:32 Edited at: 19th Apr 2009 23:44
I've been pulling my hair out, trying to get shaders to work with imported objects. Sometimes they've worked. Other times they've crashed DBP, made my objects vanish, turned my objects into tangled messes. Frustrating. I found no discussion on the forums about how to deal with this.

I think I've found a solution. If you're having similar problems, maybe this will work for you. One line of code:



Replace the object number with your own. This sets your object's FVF state to match that of the default DBP primitives, with which shaders do work.

This seems fairly remedial, really. Basic stuff. One wonders why it isn't in the docs. The documentation for Convert Object FVF is misleading, IMO. As presented, it suggests that FVF settings pertain only to vertex shader effects. A newbie like myself is easily led to ignore such a function, then, until working with vertex shaders specifically. "Oh. That's vertex shaders," I said to myself. "I'm struggling with pixel shaders. Right?" The docs also present everything in hex format, which is great for those who already understand what's going on, but useless for a beginner.



Please don't think I'm whinging, but DBP seems a bit strange about things like this. Some processes are made extremely easy - apply a shader in one line of code, using Set Bump Mapping On, for instance. So the beginner may be well represented - if the easy code works. If it doesn't, one has to hunt for a solution, and the documentation can be extremely obscure. DBP seems to jump straight from beginner to advanced in such areas. I guess the forum here is meant to pick up the slack, which is why I'm posting this.

I'm trying to track down a hex table which can allow me to translate the hex values in the Convert Object FVF listings to integer values, to post here. Then we can add up the integers to set the target FVF. If newbies like me have a simplified explanation of this sort of thing, it might help all of us.
Math89
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: UK
Posted: 19th Apr 2009 23:49
You can actually use the hex values without knowing what they represent in decimal notation. As long as you put '0x', DBPro will understand you are using hex values (for binary, use '%').

Cagedrei
15
Years of Service
User Offline
Joined: 18th Mar 2009
Location:
Posted: 20th Apr 2009 11:10 Edited at: 20th Apr 2009 23:52
Okay, I did some research, and I think I understand the FVF business a bit better.

The 274 magic does work, though. The "default" of 338 for imported objects is no good. (The calculator below reveals the 274 value to be convert object fvf object, 0x002 || 0x010 || 0x100.)

I put this together to try to understand the FVF hex math. It's an FVF calculator, which lets you add up your constants and see what you're getting. It can also try to break down an FVF value into its likely set of constants used for its construction.

Login to post a reply

Server time is: 2024-09-28 04:22:08
Your offset time is: 2024-09-28 04:22:08