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.

Dark GDK / dbSetVertexDataDiffuse Not Working

Author
Message
tparkin
17
Years of Service
User Offline
Joined: 28th Mar 2007
Location:
Posted: 8th Dec 2007 23:14 Edited at: 8th Dec 2007 23:15
Hi,



As you can see, I set the vertexdata diffuse to 10. Even after this, it outputs as 0. Why is this? I've been able to use all the other vertexdata commands with no troubles so far.

Thanks.

OT: Why is there no preview for posting on these forums?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 9th Dec 2007 13:21
It's not working as you expect because your object doesn't have the FVF format set to a value that includes diffuse.

Use the dbConvertObjectFVF function to convert the FVF to the value you need (maybe 338?) - look at the documentation for this function to see what values are available.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
tparkin
17
Years of Service
User Offline
Joined: 28th Mar 2007
Location:
Posted: 9th Dec 2007 21:13 Edited at: 9th Dec 2007 22:25
Thanks Ian. That works. Is there an RGBA() command similar to the DirectX ultility function for DarkGDK? I know there is RGB() but when setting (or getting) the Diffuse it'd be nice to easily extract each component including the alpha.


Here is the next problem:

I set the diffuse color, it outputs correctly using dbGetVertexDataDiffuse(). Now in my shader I want to use the diffuse color, but it's always zero.



If I use that in my PS the result is a black object. But I get a textured object if I don't use the diffuse color:



I am randomly setting vertices in the model to have a diffuse of black or white, so some texture should show in the first PS code snippet.

Any ideas?



Updated:

Even simpler, here is the puzzling part. When I set the diffuse color with dbSetVertexDataDiffuse, I output it with dbGetVertexdataDiffuse and it outputs correctly. I chagned my PS to just do:


The model appears all black. Why is the PS not getting the diffuse color of the model? It should have white and black verts.
tparkin
17
Years of Service
User Offline
Joined: 28th Mar 2007
Location:
Posted: 9th Dec 2007 23:53 Edited at: 9th Dec 2007 23:53
Now I'm really confused. According to the DirectX header file (and the DarkGDK help) 338 would be 152 in hex, which is:

#define D3DFVF_XYZ 0x002
#define D3DFVF_NORMAL 0x010
#define D3DFVF_DIFFUSE 0x040
#define D3DFVF_TEX0 0x000
#define D3DFVF_TEX1 0x100

Correct?

This leads me to believe that in my shader, the vertex format should be:



However, my shader only renders the object if the vertex format is this:



What am I missing?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Dec 2007 00:02
Quote: "Is there an RGBA() command"

Yes. It's a macro called D3DCOLOR_ARGB

Quote: "If I use that in my PS the result is a black object"

Remember that you are setting the vertex colour - you need to ensure that the vertex colour is passed through a vertex shader and then accepted into your pixel shader.

Unfortunately, that's as much as I can remember about that right now - I had a short spell before the convention where I was playing around with them, but I haven't touched them since. Why not pop along into the DBPro forum and post your shader into the 'Learning to write shaders' sticky thread - DBPro & GDK use the same shader system.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
tparkin
17
Years of Service
User Offline
Joined: 28th Mar 2007
Location:
Posted: 10th Dec 2007 00:06
Argh, there is no "Reply" feature of the forum!

Quote: "
Yes. It's a macro called D3DCOLOR_ARGB
"


Yes, I am familiar with DirectX macros. I was wondering if there was such in DarkGDK.

Quote: "
Remember that you are setting the vertex colour - you need to ensure that the vertex colour is passed through a vertex shader and then accepted into your pixel shader.
"


Yes, it is passed through to the PS. It seems to me like the problem is somewhere between the model and the VS.

I suppose I'll take your advice and re-post this in the DBPro thread although I'm fairly certain it isn't a shader issue per se, rather an issue of DarkGDK passing the correct model data to the shader.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Dec 2007 14:24
The dbRGB command is simply a wrapper for D3DCOLOR_ARGB.

Good luck with the rest.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
tparkin
17
Years of Service
User Offline
Joined: 28th Mar 2007
Location:
Posted: 10th Dec 2007 20:49
Just wanted to update, I've solved this issue. The vertex formats were one part of it but the next part was due to setting the shader on the wrong "limb" of the mesh. Apparently some of the sample models I was using have no limb 0 but a limb 1. It's working great now.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Dec 2007 23:03
They probably do have a limb 0, but without any mesh data. Glad you sorted it out.

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code

Login to post a reply

Server time is: 2024-11-19 20:53:43
Your offset time is: 2024-11-19 20:53:43