SUBSIM Radio Room Forums
Mods and files for every subsim!

SUBSIM: The Web's #1 BBS for all submarine and naval simulations since 1997

Go Back   SUBSIM Radio Room Forums > Silent Hunter 3 - 4 - 5 > SH5 Mods Workshop
Forget password? Reset here

Reply
 
Thread Tools Display Modes
Old 09-30-2011, 12:27 PM   #16
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,994
Downloads: 146
Uploads: 5


Default

I have a material binding problem somewhere:



After I reversed the order of the maps for a mesh subset with multiple maps I get the hull to render correctly but now the other subset (0) has an obvious incorrect material assigned to it. I have a pointer crossed somewhere.....
TheDarkWraith is offline   Reply With Quote
Old 09-30-2011, 12:59 PM   #17
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,994
Downloads: 146
Uploads: 5


Default

scratch what I said about needing to reverse the order of the maps associated with a mesh subset. I was reading and binding the maps correctly to each mesh subset. The problem was a coding error in the mesh class's render function Gotta love it....

The King GeorgeV rendered correctly:



That was the 'hardest' GR2 file in SH5 I could find to read/parse. God am I happy everything is working now
TheDarkWraith is offline   Reply With Quote
Old 09-30-2011, 02:02 PM   #18
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,994
Downloads: 146
Uploads: 5


Default

now that I can render the GR2 model correctly using the fixed-function pipeline it's time to convert to programmable pipeline. The reason I used fixed-function pipeline first was to minimize possible coding/shader errors. The goal was read and display model correctly then polish.

Now here's my question: I have only one set of texture coordinates for each vertex of each mesh. Don't I need 2 more sets of texture coordinates for the Self-Illumination (AO) and Bump (normal map)?
TheDarkWraith is offline   Reply With Quote
Old 09-30-2011, 03:00 PM   #19
Madox58
Navy Seal
 
Join Date: Dec 2006
Location: Los Angeles
Posts: 9,578
Downloads: 72
Uploads: 12
Default

Quote:
Originally Posted by TheDarkWraith View Post
Now here's my question: I have only one set of texture coordinates for each vertex of each mesh. Don't I need 2 more sets of texture coordinates for the Self-Illumination (AO) and Bump (normal map)?
Yes. You need the second set of Texcoords in the GR2 file for the AO.
There is no built in Structure in the granny2.dll to read them though.
So if your useing the same calls as used by Quark (Which came from gr2.Decode by the way) to read the PrimaryVertexData you'll never access them.

By-passing the granny2.dll allows reading (and writeing) them.
Here's the King George's AO texcoords extracted. (no granny2.dll was harmed during the extraction! ).


For the Normals, it uses the first Texcoords set.
But you need to write the code to implement Normals.
One good thing? You don't need to write the code to calculate the Normals, Tangents, or Bitangents.
Those are already in the PrimaryVertexData.
So you only need to read them.

Last edited by Madox58; 09-30-2011 at 04:34 PM.
Madox58 is offline   Reply With Quote
Old 09-30-2011, 04:33 PM   #20
reaper7
sim2reality
 
Join Date: Jun 2007
Location: AM 82
Posts: 2,278
Downloads: 254
Uploads: 32
Default

Amazing work going on here
reaper7 is offline   Reply With Quote
Old 09-30-2011, 04:45 PM   #21
Madox58
Navy Seal
 
Join Date: Dec 2006
Location: Los Angeles
Posts: 9,578
Downloads: 72
Uploads: 12
Default



But I do see a trend here.
Another 'dumbmaking tool'.


And that's fine with me!
I don't program 'pretty stuff' as others do.
I program what I need and move on.
Then I'll pass on what I know to others.
So if someone else does the fancy GUI stuff? All the better for everyone here.

If I can read and write what I want?
I don't need to see it in realtime as I already know the results before I ever put it in Game or run the program.
(90% of the time it works. I can deal with a 10% WTF rate and go back)
Madox58 is offline   Reply With Quote
Old 09-30-2011, 04:54 PM   #22
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,994
Downloads: 146
Uploads: 5


Default

ok then I need to define a structure for the second set of texture coordinates. Maybe the grannyloader.dll of SH5 can help me get to them SH5 access them somehow and just have to figure out how. I'll poke around more in the granny2.dll to see if it can extract those coordinates for me.
TheDarkWraith is offline   Reply With Quote
Old 09-30-2011, 05:02 PM   #23
Madox58
Navy Seal
 
Join Date: Dec 2006
Location: Los Angeles
Posts: 9,578
Downloads: 72
Uploads: 12
Default

It won't. I know that for a fact.
It's one reason I dropped useing the dll and went for a full understanding of the format to do what I want.

If useing built in Structures from the Granny2.dll in SH5?
You'll never get the second set of texcoords.

Those are in the second section along with all the other PrimaryVertexData information.
(Section 3 is all the faces)
Section 1 contains all the information to decide the TriGroups and MUCH more!
Madox58 is offline   Reply With Quote
Old 09-30-2011, 06:06 PM   #24
Madox58
Navy Seal
 
Join Date: Dec 2006
Location: Los Angeles
Posts: 9,578
Downloads: 72
Uploads: 12
Default

Another point.
Even if you figure out the right way to code things to use the granny2.dll?
That may violate copyrights.
Do what we want to the granny2.dll and GR2 files as long as we don't infringe.
So if you are useing something like:

nverts = (*GrannyGetMeshVertexCount)(mesh);

You may be subject to problems with RAD.
Madox58 is offline   Reply With Quote
Old 09-30-2011, 06:38 PM   #25
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,994
Downloads: 146
Uploads: 5


Default

If you bought the SH5 game you have a license to all the files contained in it. As long as I don't modify any dlls or exe there is no legal ground for anyone to stand on. Furthermore since the app asks you to point it to your granny2.dll file it is using your licensed copy of it.

Using tools from Microsoft I inspect the granny2.dll to figure out function calls. Just now I found in the exports section all the defined vertex formats that granny uses. From that information (and some trial and error) I make my code.

Just read in all the binormal and tangent information with each vertex There is not a granny vertex format defined that reads the second UV coordinates. Thus there is some function in that dll that does this. Now to find it.
TheDarkWraith is offline   Reply With Quote
Old 09-30-2011, 06:48 PM   #26
Madox58
Navy Seal
 
Join Date: Dec 2006
Location: Los Angeles
Posts: 9,578
Downloads: 72
Uploads: 12
Default

It's a special defined structure that is not in the granny2.dll
That I know.
Maybe in the grannyloader.dll granted.
I don't need those so I don't look at them.
The GR2 format is not that difficult to work with if you look at it as it is.
It's not compressed in SH5.
It's all layed out from start to EOF.
And SH5 does not do the CRC check.
Had SH5 used the CRC check?
We'd be screwed big time!!
Unless you fell back to an older granny2.dll
Madox58 is offline   Reply With Quote
Old 09-30-2011, 07:29 PM   #27
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,994
Downloads: 146
Uploads: 5


Default

ok, I think I found something interesting in the King GeorgeV.gr2 file itself:

000176E0 01 01 01 01 01 01 01 01 00 00 00 00 50 6F 73 69 ............Posi
000176F0 74 69 6F 6E 00 00 00 00 4E 6F 72 6D 61 6C 00 00 tion....Normal..
00017700 54 61 6E 67 65 6E 74 00 42 69 6E 6F 72 6D 61 6C Tangent.Binormal
00017710 00 00 00 00 54 65 78 74 75 72 65 43 6F 6F 72 64 ....TextureCoord
00017720 69 6E 61 74 65 73 30 00 54 65 78 74 75 72 65 43 inates0.TextureC
00017730 6F 6F 72 64 69 6E 61 74 65 73 31 oordinates1

Basically it tells me the vertex layout:
Position
Normal
Tangent
Binormal
TextureCoordinates0
TextureCoordinates1

so if I read in this vertex format it should work....time to try
TheDarkWraith is offline   Reply With Quote
Old 09-30-2011, 07:41 PM   #28
Madox58
Navy Seal
 
Join Date: Dec 2006
Location: Los Angeles
Posts: 9,578
Downloads: 72
Uploads: 12
Default

Yes.
All information like that is laid out in section 2 just as you see it in Grannyviewer!

It's a solid block defined by the section index and it's pointer.
Section 3 has all the faces.

That's all those sections contain.

Section 1 contains all the information as to how to divide those into seperste meshes and the textures assignments.
Plus much more.


The default for sections in a GR2 file is 8.
Max sections is 32
(That info is from the Granny history at RAD Games)

Also from a RAD Games Blog?
Most GR2 files are not modified even though Granny allows modifications.
'The First Templar' is a GREAT example of a modified GR2 file!
Easy to read/write setup for the most part.
Madox58 is offline   Reply With Quote
Old 09-30-2011, 09:57 PM   #29
Rongel
Grey Wolf
 
Join Date: Jan 2009
Location: Finland
Posts: 859
Downloads: 174
Uploads: 0
Default

I don't understand a word from that, and I don't really want to, just keep going unless police orders you to stop

This kind of stuff is the future of SH 5.

Probably the last WW2 subsim that humankind has to offer!
Rongel is offline   Reply With Quote
Old 09-30-2011, 10:02 PM   #30
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,994
Downloads: 146
Uploads: 5


Default

there looked to be a promising function in the granny2.dll: GrannyGetMeshVertexType. OllyDebug reported that it took one parameter and it was quite obvious that the one parameter was a pointer to a mesh. So I passed in the pointer to a mesh that had 2 texture coordinates per vertex defined hoping that the value returned would be a pointer to the granny vertex type defining 2 texture coordinates. I passed the returned value into the GrannyCopyMeshVertices function and looked at the returned values from that function. Result was a big fat no It only returned the correct format for the mesh with 1 texture coordinate defined as evidenced from the returned data (the bone weight and bone indicies data contained something other than 0,0,0,0) It was worth a try

Next thing is granny viewer reports VertexData. This vertex data contains descriptors defining the vertex data along with verticies for that vertex data group. Let's see what it does.....

EDIT:

I can't make the correct structure the function call requires.....All I get is garbage back......

Last edited by TheDarkWraith; 09-30-2011 at 11:25 PM.
TheDarkWraith is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 02:23 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © 1997- 2017 Subsim