Go Back   www.tombraiderforums.com > Tomb Raider Modding > Tomb Raider Level Editor > Software Development

Thread Tools
Old 04-01-13, 11:55   #11
Join Date: Feb 2006
Posts: 526

@Ensi, I have turned off "look transparency" from the moment you found the appropriate offsets and have never turned it back on (as it was the most nerving feature from my point of view) The same goes for vanishing enemies, but if I remember correctly, neither look transparency nor vanishing enemies did darken the background, so I'm not sure that it is the same kind of transparency that the EXPANDING HEAD uses. This one starts from absolutely transparent to absolutely opaque (and vice versa) darkening the background very prominently but at the same time overlaying it with the texture and color of the object.
You may catch with OLLY what exactly is called during the EXPANDING HEAD's expanding or retracting.
In the patch I added to my previous comment you may even make it all stop at one point of retraction or expansion which you can freely chose by changing the 7 parametres and observe all the attributes of the transparency at this point.
The not showing alpha behind it is actually not a big problem, but would limit the objects use to, let's say, draperies on the walls or similar. But it is just one of the, you said it yourself, many kinds of transparencies, Turbo could give it a flag and value in Strpix without any additional fixing of the effect.
HeinzFritz is offline   Reply With Quote
Old 04-01-13, 12:13   #12
TheTiger's Avatar
Join Date: Dec 2009
Location: The Hague, Netherlands
Posts: 4,335

Originally Posted by Lwmte View Post
Hi again!
During these new year long weekends, I have decided to return to something I have never accomplished back in early TREP days - decomposing TR4 renderer to bits. It's a hard one, because TR4 engine used DirectX 6 API, and it is hard to find proper D3D6 documentation these days.

Any TRLE builder knows that TR4 engine, unfortunately, lacks any blending modes except stupidest "Add" operation. Simply said, you can't have black smoke and shadows, muddy dark water, gray fog, semi-transparent realistic dark sprites, and so on, because any "translucent" surface in TR4 engine results in increased brightness of combined textures. Fortunately, DirectX allows to use almost any blending operations (inversion by colour or alpha values, colour combining, etc.), but these were never used in TR3-TR5 engine for general purpose.

Most logical and wiseful thing to do is to add these missing blending modes to TR4 engine - it is very easy, but the question is how it will be used in levels. Paolone may come up with scripting ideas (like he already did with static mesh transparency assigned via script), but I think that the best way is to assign it directly to textures. Is there some "unused" field in TR4 file format that can be used for this extra blending mode info? Right now, I have no idea - maybe experienced guys like meta2tr or sapper have some ideas?

Here are the screenies!

This is example from meta2tr demo level, two alternate blending modes: darken and screen:

By default, it looks like this:

New, really really smooth shadow, black water textures and darkened clear menu backgrounds.
I so hope that you would be able to make this compatible.
It looks incredible. Especially that round shadow and the transparency!
TheTiger is offline   Reply With Quote
Old 04-01-13, 12:25   #13
Relic Hunter
-Roli-'s Avatar
Join Date: Jul 2007
Posts: 5,479

When I read news something like these, I'm getting so excited over and over again. Our old TRLE deserve a little graphical update already.

Good luck!!!
-Roli- is offline   Reply With Quote
Old 04-01-13, 12:39   #14
Titak's Avatar
Join Date: Jul 2003
Location: Drenthe, The Netherlands
Posts: 32,555

Originally Posted by Lwmte View Post
@Titak: Hi! Right now I'm in the process of "developer hell", trying to simultaneously create new universal patcher for both TRNG and standard tomb4.exe based on classic TREP source code and also maintain backwards compatibility with classic TREP; I'm not sure how it will turn out - as Turbo Pascal says, "stay tuned"!
I'm staying tuned for sure!!!
Looks like you have a lot on your hands atm.

Originally Posted by KurtisandLara View Post
@titak: One thing I thought about if people started mAking updates for trng is, say there's multiple people each coming out with their own content, who's to say they are all compatible with one another? Since its not paolone. That's always been my concern.
My concern as well actually.
So it would be great if developers could work together with Paolone.
It might even inspire him to get back to TRNG.
If it walks like a duck and if it quacks like a duck, it is a duck.

Last edited by Titak; 04-01-13 at 22:18.
Titak is offline   Reply With Quote
Old 04-01-13, 19:47   #15
Join Date: Apr 2008
Posts: 368

I've tested setting the Texture Attributes to 0x0004 and 0x0008.

Here's what I did. I built a new meta2tr.exe (available here) that can set these Attributes according to the uv map in Metasequoia. For example:

In the image above, the five identical large squares with a vertical magenta bar are set with the attribute shown above them. To the right of the 3d image you'll see the uv map of the 5 large squares. The uv map holds five 1x1 squares offset by integer amounts. From top to bottom these correspond with attributes 4,1,0,2,8 in that order. Any uv polygons for room faces in those squares will have those attributes.

In game it looks like this:

The game doesn't crash, but the faces textured with attributes 4 and 8 don't show up.

The edited level is in the download linked above in case you're interested along with all the MQO and BMP files. It's called newlevel.tr4, and the offsets in the texture table for the 5 squares are:
0A4A: attribute 0
0A4C: attribute 1
0A4D: attribute 2
0A4E: attribute 4
0A4F: attribute 8
Hope that helps

Last edited by meta2tr; 05-01-13 at 05:09. Reason: Changed links for images
meta2tr is offline   Reply With Quote
Old 04-01-13, 20:16   #16
Turbo Pascal
Join Date: Jan 2004
Location: Central America
Posts: 111

Hi Ensi.

Maybe this can help you for your testing:


Is a old Tool called trtexture modified today (i cant beliave i found the source code in my old cd backups) which can allow you to see and to change the 16bit value called attrib for each texture entry in the texture table.

Also, for tr4 and trc levels, there is another extra 16 bit value labeled as "Flags", which most the time was documented as "unknown", actually we never had the exact details about this, but it is know that is was used for tewxtures with bumpmaps.

Object textures
The NumObjectTextures field (see TRosetta stone) is now preceeded by \0TEX (4 bytes -> \0 is the bitu8 value 0). The structure tr2_object_texture itself has changed:

// Data for an object texture (38 bytes vice 20 in TR1/2/3)
typedef struct
bitu16 Attribute; // same meaning than in TR3
bitu16 Tile; // same meaning than in TR3
bitu16 Flags; // new in TR4
tr2_object_texture_vert Vertices[4]; // same meaning than in TR3
bitu32 Unknown1,Unknown2; // new in TR4: x & y offset in something ?
bitu32 XSize,YSize; // new in TR4: width-1 & height-1 of the object texture
} tr4_object_texture;

Meaning of Flags:

Bits 0->2 mapping correction. It seems that these bits change the way the texture is applied...
Bit 11->12 2 bits giving the bump mapping type. Can be 0x01 or 0x10. It's 0x00 if not bump mapped. Only textures for room or animated textures can be bump mapped, not meshes
Bit 15 if set, the texture is for a tri/quad from a room or animated texture. If not set, the texture is for a mesh


rgbold said that the Attribute field could have a value of "2" for 2-sided textures, but it seems wrong: this field has not changed in TR4 and the value "2" seems to mean alpha=intensity as in TR3
Unknown1 and Unknown2 are said as beeing "XOffset and YOffset" by Dr.Willard, but it seems that changing these values do nothing... In addition, they seem not related to a second texturing as thought by Dr.Willard
Tile is really bits 0 through 14: bit 15 is a flag which says, if set, that this object texture is for a triangle. If not set, the object texture is for a quad.
In the texture coords now 0 is used for low value vice 1 (see the Xcoordinate and Ycoordinate fields of the tr2_object_texture_vert structure in the TRosetta Stone document)

The trtexture above version allow you to see and change that value as well; just take note, both attribs and flags are show in decimal format, you will have to use windows caculator for convert to hex or binary way.

We have a lot to catch up, another day we will see when and how we can do that; let stay tuned,

good luck.


Last edited by Turbo Pascal; 04-01-13 at 20:19.
Turbo Pascal is offline   Reply With Quote
Old 04-01-13, 22:17   #17
Lwmte's Avatar
Join Date: Aug 2010
Posts: 1,128

Hey, thank you guys, seems now we have even two different options to set these extra flags! Just what I need.

Originally Posted by Turbo Pascal
The trtexture above version allow you to see and change that value as well; just take note, both attribs and flags are show in decimal format, you will have to use windows caculator for convert to hex or binary way.
Well! Interestingly enough, it seems that engine treats "Attributes" value not like array of bits, but just like integer. This "Attributes" value is nothing else but this internal TR4 face subtype index, only difference between processing room / object / static faces and any other faces (sprites, effects, sky, etc.) is that TR4 engine simply BYPASSES subtypes above 2 for them! So that's why you, meta2tr, have no effect with texture attributes above 2 applied to room faces. Here's the code part from TR4 exe:

CPU Disasm
Address   Hex dump                    Command                      Comments

00470BDD  |.  85C9                    TEST ECX,ECX                 ; If Attribute=0 (Opaque)...
00470BDF  |.  74 29                   JZ SHORT 00470C0A            ; Jump to dx_core_AddToScene_OPAQUE
00470BE1  |.  7E 4A                   JLE SHORT 00470C2D           ; If Attribute=-1, bypass this TexInfo...
00470BE3      83F9 02                 CMP ECX,2 
00470BE6  |.  7F 45                   JG SHORT 00470C2D            ; !!!!! Room faces attribute limiter 2
00470BE8  |.  66:8B4E 04              MOV CX,WORD PTR DS:[ESI+4] 
00470BEC  |.  50                      PUSH EAX                     ; Argument 7
00470BED  |.  66:8B46 06              MOV AX,WORD PTR DS:[ESI+6]
00470BF1  |.  52                      PUSH EDX                     ; Argument 6
00470BF2  |.  66:8B56 02              MOV DX,WORD PTR DS:[ESI+2]
00470BF6  |.  50                      PUSH EAX                     ; Argument 5
00470BF7  |.  66:8B06                 MOV AX,WORD PTR DS:[ESI]
00470BFA  |.  51                      PUSH ECX                     ; Argument 4
00470BFB  |.  8B4C24 24               MOV ECX,DWORD PTR SS:[ARG.5]
00470BFF  |.  52                      PUSH EDX                     ; Argument 3
00470C00  |.  50                      PUSH EAX                     ; Argument 2
00470C01  |.  51                      PUSH ECX                     ; Argument 1
00470C02  |.  FF15 A4395300           CALL DWORD PTR DS:[5339A4]   ;  dx_core_AddToScene_TRANS
So, you can easily enable subtypes 3-7 by modifying only two bytes in tomb4.exe at offsets 7BF7D and 70BE5. Change them from 02 to 07, and you can freely use extra 5 subtypes for room faces too!

Interesting thing is that subtype 7 is used for forced numerical alpha value transparency (as described above - it goes for look transparency, vanishing enemies, god head and Paolone's static meshes OCBs and scripted fades). So theoretically, we can use upper byte of Attributes field (as it's never used for any other purposes) for setting up alpha value. This way we can have "forced alpha" faces in room geometry too.
Lwmte is offline   Reply With Quote
Old 04-01-13, 22:21   #18
Titak's Avatar
Join Date: Jul 2003
Location: Drenthe, The Netherlands
Posts: 32,555

@ meta2tr:
Can't see the pictures...

@ Lwmte and Turbo Pascal:
No idea what you guys are talking about!
But please do keep talking. Something good will come out of it, I'm sure of it.
If it walks like a duck and if it quacks like a duck, it is a duck.
Titak is offline   Reply With Quote
Old 04-01-13, 22:23   #19
Laras Boyfr.
Laras Boyfr.'s Avatar
Join Date: Jul 2009
Location: Albania
Posts: 4,742

I skipped the chinese and now am asking ... so its possible to implement these features?
Laras Boyfr. is offline   Reply With Quote
Old 04-01-13, 22:24   #20
Laras Boyfr.
Laras Boyfr.'s Avatar
Join Date: Jul 2009
Location: Albania
Posts: 4,742

Originally Posted by Titak View Post
@ meta2tr:
Can't see the pictures...
Fixed link

EDIT: Aaargh, sorry for double post
Laras Boyfr. is offline   Reply With Quote

Thread Tools

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

All times are GMT. The time now is 13:31.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.