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 / Texturing an object

Author
Message
scott1686
15
Years of Service
User Offline
Joined: 27th Jan 2009
Location:
Posted: 31st Jan 2009 21:59
Is there anyway to take a .x object that has no texture and give it both a texture and a detail, like the dbSetTerrainTexture function but for objects instead of terrains? I keep trying to set both a texture and a detail for a large object but it just keeps changing it to a different solid color. If that's not possible, is there at least a way to make the texture smaller and repeat over the surface of the entire large 3D object? Thanks.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 1st Feb 2009 00:05
I think So and Yes.

Quote: "Is there anyway to take a .x object that has no texture and give it both a texture and a detail"
Yes. I think you need the correct FVF format, thats how the model vertex data is stored under the hood. The reason? You can have just points, points and normals (for lighting), Points, Normals, UV (for one texture), or points + normals + uv for texture 0 + uv for texture 1 etc.

There are numeric codes that are used to build the right FVF format value. I'm not sure if all combinations (which will typically work fine in DirectX) will work in DarkGDK.



There is a call called dbSetFVFFormat or something in DarkGDK. I'm pretty sure you call this on existing Objects and it handles things you you.

THEN I THINK you apply your base texture to TEXTURE 0 (Like you normally would apply a texture to an object) Then I think you apply your "detail" texture to TEXTURE 1 (Note this is assuming you selected an FVF format with Points + Normals + TEX0 + TEX1 and applied it to the object first)... then I think you call dbSetDetailShading on or something like that.

I haven't personally tried this - but I'm pretty certain it uses a "built" in shader inside DarkGDK to perform its magic. I do remember having a conversation via forums or something where someone disagreed with me about this "built in shader" being the way it works under the hood - and although we disagreed - I think you should be aware of both of these points of view to better help you work something out hopefully.

Good Luck,
sorry I couldn't be of more help.

scott1686
15
Years of Service
User Offline
Joined: 27th Jan 2009
Location:
Posted: 2nd Feb 2009 01:33
Thanks for the help. I found some function in the documentation called dbConvertObjectFVF ( int iObject, int iFVFFormat ), so what number would I have to give in iFVFFormat then? I'm assuming it's a sum of the value of each of those parameters that you gave me, but which ones exactly will I need? And am I basically just setting the textures first before calling this function then? Thanks.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 2nd Feb 2009 02:11
yeah you add them up.

Which Ones? I've read SOME posts - some people say some work better than others.

Usually you call the FVF first before you hunker down and assign a ton of textures.

I personally use 338. I'm rushed ATM so I'll leave you to reverse enginner what that value has in it... it does work though - follow my signature to the web site and see what I've been doing

Good Luck - Post again if you hit another snag
--Jason

scott1686
15
Years of Service
User Offline
Joined: 27th Jan 2009
Location:
Posted: 2nd Feb 2009 16:21
It still doesn't seem to be working, right now it just basically seems to blend the average color of the texture and detail and change the walls to that color. Here's what I have:



Am I doing something out of order? I tried moving around the call to the FVF function and I tried other values as a parameter but still no luck. I'm using the same image for the texture and detail just for testing since I've done that for grass on my terrain and it worked out fine. Thanks for the help.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 2nd Feb 2009 19:09
I'm pressed for time - Sorry about that - but I can say it looks right. Definately in the right order. I did notice you're loading the same image twice in your snippet - but... perhaps if the DarkGDK built in detail mapping is being problematic, you try a shader or two from other sources. Green Gandalf is known for writing some good ones and so is "Evolved"... He has a shader pack with a variety of shaders that might help you with your problem.

--Jason

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Feb 2009 21:42
The two 'favourite' FVF formats are 338 (xyz, normals, 1 texture & diffuse) and 274 (xyz, normals & 1 texture). Doing this will convert an objects existing FVF format to the format you specify, but it will not invent information.

What I mean by that is that if you have an existing FVF format that excludes texture coordinates, converting the FVF will add space in the format to hold texture coordinates, but they'll all be set to zero. It's up to you to set them all.

If your object is a text format .x file, open it up in notepad and look for 'MeshTextureCoords' - if there is one or more occurrences of this then you have texture coordinates, if not, you don't.

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 2nd Feb 2009 22:29
Hmm... I guess I can't explain why I'm able to use GG's Terrain shader - I thought 338 had all texture uv space allocated... ugh... must investigate!

--Jason

(And IanM is saying you have to put your UV values in there for textures after Texture0 ... so they know how to texture... Hmm.. Easier to write routines for this when you have known squares/ poly layouts... like terrain: for odd shaped things its a triffle harder though you can cheat and make a routine copy the UV values from texture ZERO and copy that data to Texture1, texture2, texture3 etc.)

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Feb 2009 22:39
Quote: "I thought 338 had all texture uv space allocated... ugh... must investigate!"

It does. You have 1 set of texture coordinates.
Both of those formats have 1 set of texture coordinates.

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 2nd Feb 2009 22:43
Oh - So you're saying (I think) that one set of coords will be shared by all textures applied (0-7) and if you use another format where there are separate UV coords... then "Hey - Put data in there!" ... right?

(Appreciate the help - I got confussed )
--Jason

scott1686
15
Years of Service
User Offline
Joined: 27th Jan 2009
Location:
Posted: 2nd Feb 2009 22:51
Quote: "If your object is a text format .x file, open it up in notepad and look for 'MeshTextureCoords' - if there is one or more occurrences of this then you have texture coordinates, if not, you don't.
"


I checked this, and there wasn't any data there, so then I played around with Blender a little and found a setting to add that data into the model. Now it works the way I want it to, so thanks for the help!
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 2nd Feb 2009 22:59
Awesome - So did the dbSetDetailMappingOn thing work too?

david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 2nd Feb 2009 23:03
you need to use the blend mapping functions from or use a shader to do what you want. Its not that hard. You just have to find the right combination. My GDK dont work, because Im using the latest DX SDK but I could make a simple sample in dbp for you and then you can convert it if you like.

Let me know and I'll post it.
scott1686
15
Years of Service
User Offline
Joined: 27th Jan 2009
Location:
Posted: 2nd Feb 2009 23:23
Quote: "Awesome - So did the dbSetDetailMappingOn thing work too?"


Yeah, that worked too. Although now that I'm looking more closely at the results, there seems to be one more minor issue. Whenever the textures are applied to faces that aren't running parallel with an axis, they seem to refresh really unevenly, so it looks like the textures vibrate or something. Did anyone else ever have this problem, and if so, is there any way to fix it? Thanks.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Feb 2009 23:53
You could try disabling mip-mapping on the object - the function to do that is dbSetObjectTexture. Use a texture mode and mipmap settings of 0 and see how that looks.

scott1686
15
Years of Service
User Offline
Joined: 27th Jan 2009
Location:
Posted: 3rd Feb 2009 00:35
It turned out I just had the culling set wrong, so once I fixed that it looked fine. Thanks for the help everyone!
CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 3rd Feb 2009 08:40
Quote: "I checked this, and there wasn't any data there, so then I played around with Blender a little and found a setting to add that data into the model. Now it works the way I want it to, so thanks for the help!"


Wait, what setting? I also need help with .x models, I cannot texture them, they are still white!
scott1686
15
Years of Service
User Offline
Joined: 27th Jan 2009
Location:
Posted: 3rd Feb 2009 16:40
Quote: "Wait, what setting? I also need help with .x models, I cannot texture them, they are still white!"


If you go to the editing panel (F9) and look under the Mesh tab, there's a thing that says UV Texture with a button that says "New" next to it. I just clicked on the "New" button and left the default data there and it added in the texture data to the .X model.

Login to post a reply

Server time is: 2024-11-25 13:34:02
Your offset time is: 2024-11-25 13:34:02