Jump to content


Photo

MD3 models?


37 replies to this topic

#1 rich_is_bored

rich_is_bored

    Advanced Member

  • Member
  • PipPipPip
  • 819 posts

Posted 15 February 2017 - 02:25 AM

I was working my way through the code and noticed the game supports loading MD3 models. I can't believe Doom 3 has been around for 12 years and nobody played around with this. Vertex animation is a bit dated but it still has valid use cases.

 

Of course I was immediately sidetracked. I had to track down an exporter for Blender and try it.

 

Nothing complicated. Just a sphere with a wave modifier on it. I've packaged it up if anyone would like to tinker. It's testmd3.pk4.

 

If you load the model you'll note that it doesn't animate. But there's a bit of code in Model_md3.cpp that's of interest...

    // TODO: these need set by an entity

    frame = ent->shaderParms[SHADERPARM_MD3_FRAME];            // probably want to keep frames < 1000 or so

    oldframe = ent->shaderParms[SHADERPARM_MD3_LASTFRAME];

    backlerp = ent->shaderParms[SHADERPARM_MD3_BACKLERP];

These shaderparm references translate into parms 8, 9, and 10. I have determined that setting shaderparm 8 changes the current frame. You can see for yourself by loading the model with "testModel models/test.md3" and advancing frames with "testShaderParm 8 [frame]".

 

Anyway. Just sharing my findings. Maybe I'll figure it out a way to make use of this eventually.


  • Judith, nbohr1more and Anderson like this

#2 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 7288 posts

Posted 15 February 2017 - 09:09 AM

I think Arcturus did some fake cloth physics by baking animation to models then used animation commands to swap models.

This seems to be a better way to achieve that. This may also come in handy for water effects.

 

Edit:

 

I might be remembering wrong. All I can find is a baked bone animation:

 

http://forums.thedar...e-3#entry353012

 

still, using vertex animation instead should reduce the amount of calculation needed for these effects as I gather.

(At the expense of more storage and memory.)


Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

(Yeah, shameless promotion... but traffic is traffic folks...)

#3 Judith

Judith

    Member

  • Member
  • PipPip
  • 277 posts

Posted 15 February 2017 - 09:13 AM

I guess nobody was using this because this is legacy Quake 3 animation model: http://www.misfitcod...h_quakemd3.html



#4 Arcturus

Arcturus

    Advanced Member

  • Development Role
  • PipPipPip
  • 1562 posts

Posted 15 February 2017 - 12:19 PM

Yes, I tried to overcome lack of vertex animation by baking cloth physics to bones. Rather tedious. I recall Motorsep trying to hire someone to write a Blender script for that (?)


  • nbohr1more likes this

It's only a model... /// My channel on YouTube /// CGtrader , Turbosquid


#5 rich_is_bored

rich_is_bored

    Advanced Member

  • Member
  • PipPipPip
  • 819 posts

Posted 15 February 2017 - 03:18 PM

I recall back on the D3W forums der_ton wrote an experimental MD5 exporter that baked vertex animation by creating a bone for every vertex. It's funny looking back on it as we were clearly shoving a square peg into a round hole.

 

At any rate, I initially was going to use a Q3 character model for testing purposes since they could be found everywhere. But then I saw how they are split into three separate MD3s, paired with a CFG, and the code doesn't appear to reflect this. I'm fine with that however. MD5 is far superior for character models with fewer keyframes, support for frame events, interpolation, ect. We'd only be using MD3 for props like grass, fabric, and spider webs blowing in the wind.



#6 rich_is_bored

rich_is_bored

    Advanced Member

  • Member
  • PipPipPip
  • 819 posts

Posted 16 February 2017 - 01:09 AM

*
POPULAR

Got an update...

 

 

And the package, md5test.pk4 including the example map, models, and scriptobject required to make use of this yourself.


  • Springheel, Bikerdude, Arcturus and 9 others like this

#7 Arcturus

Arcturus

    Advanced Member

  • Development Role
  • PipPipPip
  • 1562 posts

Posted 16 February 2017 - 02:15 AM

Nice.


It's only a model... /// My channel on YouTube /// CGtrader , Turbosquid


#8 grayman

grayman

    Master Builder, Coder

  • Active Developer
  • PipPipPipPipPip
  • 11493 posts

Posted 16 February 2017 - 10:35 AM

This is very nice.

 

I'll see if I can apply it to the surface of the Fire Elemental for 2.06, which would be a nice improvement. I imagine I'll be picking up a few changes for the FE as people start to put it into their maps.

 

Thanks!



#9 Obsttorte

Obsttorte

    Scripting guru, Mapper

  • Active Developer
  • PipPipPipPip
  • 4733 posts

Posted 16 February 2017 - 12:48 PM

Very nice work.

 

I may add that such effects can be achieved using vertex shaders either. The question would be which way is easier and less performance consuming, though.

 

As md5 is most probably a successor of md3, I am wondering whether the same stuff could be achieved with normal md5's either.


FM's: Builder Roads, Old Habits, Old Habits Rebuild
WIP's: Several. Although after playing Thief 4 I really wanna make a city mission.
Mapping and Scripting: Apples and Peaches
Sculptris Models and Tutorials: Obsttortes Models
My wiki articles: Obstipedia
Let's Map TDM YouTube playlist: ObstlerTube
Texture Blending in DR: DR ASE Blend Exporter

End of shameless self promotion.

#10 HMart

HMart

    Member

  • Member
  • PipPip
  • 463 posts

Posted 16 February 2017 - 10:24 PM

Very nice work.

 

I may add that such effects can be achieved using vertex shaders either. The question would be which way is easier and less performance consuming, though.

 

As md5 is most probably a successor of md3, I am wondering whether the same stuff could be achieved with normal md5's either.

 

Very nice work indeed!!

 

You can achive something similar to this with Md5 but only using bones and is more time consuming.

 

Btw i knew that idtech 4 add a MD3 loader but i always thought it was old legacy code that didn't worked!

 

I also assume modern exporters for this old format aren't plenty?


Edited by HMart, 16 February 2017 - 10:27 PM.


#11 rich_is_bored

rich_is_bored

    Advanced Member

  • Member
  • PipPipPip
  • 819 posts

Posted 16 February 2017 - 11:48 PM

@Obsttorte

 

I'm sure a vertex shader would be better for performance. My concern is the custom shaders we call from our materials are executed after interaction.vfp. Will you see any changes to vertex positions if they are rendered before they are moved?



#12 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 7288 posts

Posted 17 February 2017 - 12:09 AM

(AFAIK) Yes, currently you'd need to distort _currentRender or jump through hoops re-rendering the whole lighting pipeline

to make that work.

 

That said, perhaps I can look into changing the place in the pipeline where vertex arb can be

inserted. Ideally we'd do what the shadow.vp does and write to the VBO before the lighting process begins.


Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

(Yeah, shameless promotion... but traffic is traffic folks...)

#13 Obsttorte

Obsttorte

    Scripting guru, Mapper

  • Active Developer
  • PipPipPipPip
  • 4733 posts

Posted 17 February 2017 - 01:40 AM

@Obsttorte

 

I'm sure a vertex shader would be better for performance. My concern is the custom shaders we call from our materials are executed after interaction.vfp. Will you see any changes to vertex positions if they are rendered before they are moved?

I played around with vertex shaders moving vertices and it works. I've used it to create water waves.


  • AluminumHaste likes this
FM's: Builder Roads, Old Habits, Old Habits Rebuild
WIP's: Several. Although after playing Thief 4 I really wanna make a city mission.
Mapping and Scripting: Apples and Peaches
Sculptris Models and Tutorials: Obsttortes Models
My wiki articles: Obstipedia
Let's Map TDM YouTube playlist: ObstlerTube
Texture Blending in DR: DR ASE Blend Exporter

End of shameless self promotion.

#14 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 7288 posts

Posted 17 February 2017 - 01:51 AM

;) Water is transparent...

 

The arb programs work as long as you are doing some sort of transparency. You can hack them back to opaque of course.

Depends on how much juggling you wanna do:

 

http://wiki.thedarkm...parent_textures


Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

(Yeah, shameless promotion... but traffic is traffic folks...)

#15 Obsttorte

Obsttorte

    Scripting guru, Mapper

  • Active Developer
  • PipPipPipPip
  • 4733 posts

Posted 17 February 2017 - 02:08 AM

If I can dig out the files related to the water I could check whether it works with opaque surfaces either.


FM's: Builder Roads, Old Habits, Old Habits Rebuild
WIP's: Several. Although after playing Thief 4 I really wanna make a city mission.
Mapping and Scripting: Apples and Peaches
Sculptris Models and Tutorials: Obsttortes Models
My wiki articles: Obstipedia
Let's Map TDM YouTube playlist: ObstlerTube
Texture Blending in DR: DR ASE Blend Exporter

End of shameless self promotion.

#16 Arcturus

Arcturus

    Advanced Member

  • Development Role
  • PipPipPip
  • 1562 posts

Posted 18 February 2017 - 08:13 AM

I'm trying to wrap my head around this.

    {
        setShaderParm(8, currentFrame);
        currentFrame = (currentFrame + 1) % numFrames;
        sys.waitFrame();
    }

Does this depend on current FPS? I made a test md3 with two frames. I want to play one frame per second. I also would like to animate texture so that first image is displayed exactly at frame one and second image at frame two. I could add sixty of these: sys.waitFrame();

Spoiler
That will play at roughly 1 FPS.

I use this material:

anim_test
{
    noshadows
    noimpact
    nonsolid
    {
        if ( (time * 1) % 2 == 0 )
        blend blend
        alpha 1
        map    textures/anim_test/anim_test_01.tga
    }
    {
        if ( (time * 1) % 2 == 1 )
        blend blend
        alpha 1
        map    textures/anim_test/anim_test_02.tga
    }
}

Time means seconds here?

If I set up the script and material like this they both play at roughly 1 FPS but never exactly in sync. Do I get it right that one is dependent on FPS and other not?


It's only a model... /// My channel on YouTube /// CGtrader , Turbosquid


#17 Bikerdude

Bikerdude

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 17823 posts

Posted 18 February 2017 - 10:21 AM

I like the cobweb anim, how would a newbie mapper implement that in thier map..?



#18 Obsttorte

Obsttorte

    Scripting guru, Mapper

  • Active Developer
  • PipPipPipPip
  • 4733 posts

Posted 18 February 2017 - 11:49 AM

;) Water is transparent...

 

The arb programs work as long as you are doing some sort of transparency. You can hack them back to opaque of course.

Depends on how much juggling you wanna do:

 

http://wiki.thedarkm...parent_textures

 

If I can dig out the files related to the water I could check whether it works with opaque surfaces either.

Found the files and testet it. It works.

 

Note that the vertex shader only affects the visual representation, not the physics (= collision). But I'm not sure whether the md3 examples above would do so either.

 

However, in case of moving cobwebs (why is it called like that, aren't those spiderwebs?) or waves you don't expect them to be solid anyways (unless you want to make a FM where the player can walk over water, preferable after he had turned it into wine :P ).


FM's: Builder Roads, Old Habits, Old Habits Rebuild
WIP's: Several. Although after playing Thief 4 I really wanna make a city mission.
Mapping and Scripting: Apples and Peaches
Sculptris Models and Tutorials: Obsttortes Models
My wiki articles: Obstipedia
Let's Map TDM YouTube playlist: ObstlerTube
Texture Blending in DR: DR ASE Blend Exporter

End of shameless self promotion.

#19 rich_is_bored

rich_is_bored

    Advanced Member

  • Member
  • PipPipPip
  • 819 posts

Posted 19 February 2017 - 01:49 AM

@Arcturus

 

Yes, the scriptobject as currently constructed is linked to FPS. To base it on a set duration instead you would use...

sys.wait(X);

... where X is the number of seconds.

 

I'm sure you've noticed that the engine does not interpolate between keyframes? I figured smooth playback was preferable so I coupled playback to FPS.

 

In your case, why not export two static models each with their own material? Then you can toggle their visibility on or off at 1 FPS and you won't have to worry about sync issues. The script events you're interested in are "show" and "hide".

 

@Bikerdude

 

Hold that thought. If Obsttorte's shader works nobody will need to model anything.

 

@Obsttorte

 

If you could put those files into a package and make it available somewhere I'd like to see it.



#20 Arcturus

Arcturus

    Advanced Member

  • Development Role
  • PipPipPip
  • 1562 posts

Posted 19 February 2017 - 06:05 AM

I used 2 frames just as an example. What I really want to do is to have an ocean with 50 frames that plays at 24-30 FPS. I want to bake normalmap for each frame so I would like them to align, although it's not super important. At 60 FPS I would need twice as many frames for a nice loop and I thought that would be an overkill.

 

I used sys.wait(1); and they still don't synchronize perfectly.


It's only a model... /// My channel on YouTube /// CGtrader , Turbosquid


#21 Arcturus

Arcturus

    Advanced Member

  • Development Role
  • PipPipPip
  • 1562 posts

Posted 19 February 2017 - 04:02 PM

*
POPULAR

Here's a 50-frame md3 waves animation with animated texture.

 

 

I used this experimental shader by SteveL with addition of specular reflections. It looks great on the shore. Too bad that further away all the reflections and refractions are masked leaving only the diffusemaps.


  • Bikerdude, AluminumHaste, rich_is_bored and 4 others like this

It's only a model... /// My channel on YouTube /// CGtrader , Turbosquid


#22 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 35803 posts

Posted 19 February 2017 - 04:12 PM

Oh man, that looks fantastic!  It's exactly what I was looking for when I was working on the harbour mission.


  • AluminumHaste likes this
Posted Image

#23 Bikerdude

Bikerdude

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 17823 posts

Posted 19 February 2017 - 05:30 PM

I used this experimental shader by SteveL with addition of specular reflections. It looks great on the shore. Too bad that further away all the reflections and refractions are masked leaving only the diffusemaps.

This is amazing, would it be possible to get the edges of the wster where is touch another brush/shader to foam/white -

 

- https://forum.unity3...m-water.381288/

 



#24 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 35803 posts

Posted 19 February 2017 - 06:46 PM

That's probably done with a particle emitter, I imagine. Would be nice to have one.
Posted Image

#25 Obsttorte

Obsttorte

    Scripting guru, Mapper

  • Active Developer
  • PipPipPipPip
  • 4733 posts

Posted 20 February 2017 - 04:02 AM

The white foam could be applied via the shader me thinks as it occours were the water is not very deep.


FM's: Builder Roads, Old Habits, Old Habits Rebuild
WIP's: Several. Although after playing Thief 4 I really wanna make a city mission.
Mapping and Scripting: Apples and Peaches
Sculptris Models and Tutorials: Obsttortes Models
My wiki articles: Obstipedia
Let's Map TDM YouTube playlist: ObstlerTube
Texture Blending in DR: DR ASE Blend Exporter

End of shameless self promotion.



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users