rich_is_bored 281 Posted February 15, 2017 Report Share Posted February 15, 2017 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. 3 Quote ModWiki Link to post Share on other sites
nbohr1more 2163 Posted February 15, 2017 Report Share Posted February 15, 2017 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.thedarkmod.com/topic/16469-model-request-furniture-covered-in-sheets/page-3?do=findComment&comment=353012 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.) Quote Please visit TDM's IndieDB site and help promote the mod: http://www.indiedb.com/mods/the-dark-mod (Yeah, shameless promotion... but traffic is traffic folks...) Link to post Share on other sites
peter_spy 1603 Posted February 15, 2017 Report Share Posted February 15, 2017 I guess nobody was using this because this is legacy Quake 3 animation model: http://www.misfitcode.com/misfitmodel3d/olh_quakemd3.html Quote Misc. assets for TDM Link to post Share on other sites
Arcturus 694 Posted February 15, 2017 Report Share Posted February 15, 2017 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 (?) 1 Quote It's only a model... Link to post Share on other sites
rich_is_bored 281 Posted February 15, 2017 Author Report Share Posted February 15, 2017 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. Quote ModWiki Link to post Share on other sites
Popular Post rich_is_bored 281 Posted February 16, 2017 Author Popular Post Report Share Posted February 16, 2017 Got an update... And the package, md5test.pk4 including the example map, models, and scriptobject required to make use of this yourself. 13 Quote ModWiki Link to post Share on other sites
Arcturus 694 Posted February 16, 2017 Report Share Posted February 16, 2017 Nice. Quote It's only a model... Link to post Share on other sites
grayman 2974 Posted February 16, 2017 Report Share Posted February 16, 2017 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! Quote Link to post Share on other sites
Obsttorte 1519 Posted February 16, 2017 Report Share Posted February 16, 2017 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. Quote FM's: Builder Roads, Old Habits, Old Habits Rebuild Mapping and Scripting: Apples and Peaches Sculptris Models and Tutorials: Obsttortes Models My wiki articles: Obstipedia Texture Blending in DR: DR ASE Blend Exporter Link to post Share on other sites
HMart 334 Posted February 17, 2017 Report Share Posted February 17, 2017 (edited) 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 February 17, 2017 by HMart Quote Link to post Share on other sites
rich_is_bored 281 Posted February 17, 2017 Author Report Share Posted February 17, 2017 @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? Quote ModWiki Link to post Share on other sites
nbohr1more 2163 Posted February 17, 2017 Report Share Posted February 17, 2017 (AFAIK) Yes, currently you'd need to distort _currentRender or jump through hoops re-rendering the whole lighting pipelineto make that work. That said, perhaps I can look into changing the place in the pipeline where vertex arb can beinserted. Ideally we'd do what the shadow.vp does and write to the VBO before the lighting process begins. Quote Please visit TDM's IndieDB site and help promote the mod: http://www.indiedb.com/mods/the-dark-mod (Yeah, shameless promotion... but traffic is traffic folks...) Link to post Share on other sites
Obsttorte 1519 Posted February 17, 2017 Report Share Posted February 17, 2017 @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. 1 Quote FM's: Builder Roads, Old Habits, Old Habits Rebuild Mapping and Scripting: Apples and Peaches Sculptris Models and Tutorials: Obsttortes Models My wiki articles: Obstipedia Texture Blending in DR: DR ASE Blend Exporter Link to post Share on other sites
nbohr1more 2163 Posted February 17, 2017 Report Share Posted February 17, 2017 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.thedarkmod.com/index.php?title=Making_Semi-transparent_textures Quote Please visit TDM's IndieDB site and help promote the mod: http://www.indiedb.com/mods/the-dark-mod (Yeah, shameless promotion... but traffic is traffic folks...) Link to post Share on other sites
Obsttorte 1519 Posted February 17, 2017 Report Share Posted February 17, 2017 If I can dig out the files related to the water I could check whether it works with opaque surfaces either. Quote FM's: Builder Roads, Old Habits, Old Habits Rebuild Mapping and Scripting: Apples and Peaches Sculptris Models and Tutorials: Obsttortes Models My wiki articles: Obstipedia Texture Blending in DR: DR ASE Blend Exporter Link to post Share on other sites
Arcturus 694 Posted February 18, 2017 Report Share Posted February 18, 2017 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(); { setShaderParm(8, currentFrame); currentFrame = (currentFrame + 1) % numFrames; sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); sys.waitFrame(); } 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? Quote It's only a model... Link to post Share on other sites
Bikerdude 3741 Posted February 18, 2017 Report Share Posted February 18, 2017 I like the cobweb anim, how would a newbie mapper implement that in thier map..? Quote Link to post Share on other sites
Obsttorte 1519 Posted February 18, 2017 Report Share Posted February 18, 2017 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.thedarkmod.com/index.php?title=Making_Semi-transparent_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 ). Quote FM's: Builder Roads, Old Habits, Old Habits Rebuild Mapping and Scripting: Apples and Peaches Sculptris Models and Tutorials: Obsttortes Models My wiki articles: Obstipedia Texture Blending in DR: DR ASE Blend Exporter Link to post Share on other sites
rich_is_bored 281 Posted February 19, 2017 Author Report Share Posted February 19, 2017 @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. Quote ModWiki Link to post Share on other sites
Arcturus 694 Posted February 19, 2017 Report Share Posted February 19, 2017 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. Quote It's only a model... Link to post Share on other sites
Popular Post Arcturus 694 Posted February 19, 2017 Popular Post Report Share Posted February 19, 2017 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. 8 Quote It's only a model... Link to post Share on other sites
Springheel 4645 Posted February 19, 2017 Report Share Posted February 19, 2017 Oh man, that looks fantastic! It's exactly what I was looking for when I was working on the harbour mission. 1 Quote TDM Missions: A Score to Settle * A Reputation to Uphold * A New Job * A Matter of Hours Video Series: Springheel's Modules * Speedbuild Challenge * New Mappers Workshop * Building Traps Link to post Share on other sites
Bikerdude 3741 Posted February 19, 2017 Report Share Posted February 19, 2017 (edited) 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 water where is touches another brush/shader to foam-up - - https://forum.unity3d.com/threads/release-calm-water.381288/ Edited October 14, 2018 by Bikerdude Quote Link to post Share on other sites
Springheel 4645 Posted February 19, 2017 Report Share Posted February 19, 2017 That's probably done with a particle emitter, I imagine. Would be nice to have one. Quote TDM Missions: A Score to Settle * A Reputation to Uphold * A New Job * A Matter of Hours Video Series: Springheel's Modules * Speedbuild Challenge * New Mappers Workshop * Building Traps Link to post Share on other sites
Obsttorte 1519 Posted February 20, 2017 Report Share Posted February 20, 2017 The white foam could be applied via the shader me thinks as it occours were the water is not very deep. Quote FM's: Builder Roads, Old Habits, Old Habits Rebuild Mapping and Scripting: Apples and Peaches Sculptris Models and Tutorials: Obsttortes Models My wiki articles: Obstipedia Texture Blending in DR: DR ASE Blend Exporter Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.