{"id":882,"date":"2009-06-16T00:04:11","date_gmt":"2009-06-15T23:04:11","guid":{"rendered":"\/blog\/?p=882"},"modified":"2009-06-16T00:04:11","modified_gmt":"2009-06-15T23:04:11","slug":"openbve-v1071-released-performance-improvements-and-new-object-features","status":"publish","type":"post","link":"https:\/\/railsimroutes.net\/blog\/openbve\/openbve-v1071-released-performance-improvements-and-new-object-features\/","title":{"rendered":"openBVE v1.0.7.1 released; performance improvements and new object development features"},"content":{"rendered":"<p>openBVE v1.0.7.1 is now available; I&#8217;d recommend heading over to the <span style=\"white-space: nowrap;\"><a href=\"http:\/\/openbve.trainsimcentral.co.uk\/\" target=\"_blank\" rel=\"noopener\">\u00bb openBVE homepage \u00ab<\/a><\/span> to download the latest stable release, and don&#8217;t forget to read the <span style=\"white-space: nowrap;\"><a href=\"http:\/\/openbve.trainsimcentral.co.uk\/changelog.html\" target=\"_blank\" rel=\"noopener\">\u00bb Changelog \u00ab<\/a><\/span> for a full list of alterations and new features.<\/p>\n<p style=\"padding-left: 30px;\"><img decoding=\"async\" style=\"padding-right: 4px; float: left; padding-bottom: 25px;\" src=\"\/interface\/themes\/modern\/icons\/information_32.png\" alt=\"Information Icon\" \/> <strong>Update (18th June):<\/strong> <span class=\"emphasis_colour_bold\">openBVE v1.0.7.2 was released yesterday<\/span>. This version includes a bugfix relating to problems when some objects were loaded, which also resulted in error messages. As far as I&#8217;m aware, the objects concerned were those with meshbuilder blocks containing both Cylinder commands <em>and<\/em> AddFace commands referencing the cylinder&#8217;s vertices, which should now be loaded without any problems in v1.0.7.2.<\/p>\n<p>This release can offer some potentially superb performance improvements on some routes. With <a href=\"\/x-city_south\/\">Cross-City South v1.31.02<\/a>, and 8x antialiasing\/16x anisotropic filtering set via my graphics card drivers, along with bilinear interpolation set via openBVE&#8217;s options, I see between <strong>20-35% increases<\/strong> in framerates compared to openBVE v1.0.6.2 with identical settings. With anisotropic filtering and smooth transparency enabled via openBVE&#8217;s settings, I also see between around <strong>25-46% increases<\/strong> in framerates with identical settings in both openBVE versions. So for example, where the entrance to Birmingham New Street used to take me down to 15 fps with smooth transparency enabled, now I can reach a much more fluid 21-22 fps. I won&#8217;t publish any figures regarding Cross-City South v1.4 yet, as the route is still in development and the performance level changes often as I experiment with it. These results are obtained on an AMD Athlon 64 X2 4200+ @ 2.2GHz, 2GB DDR2-800 CL5-5-5-15, ATi Radeon HD 2600 Pro 256MB DDR2 PCIe equipped system by the way.<\/p>\n<p>The improvement which has most impressed me though, is the performance of openBVE v1.0.7.1 with <strong>Watford Junction to Rugby<\/strong>. To say that I&#8217;m delighted would be a massive understatement, as I&#8217;ve seen between <strong>30-160% increases in framerate<\/strong> compared to v1.0.6.2! Generally though, framerates of around 17-21 fps (on the four track sections between stations, in the external view with those nice AC electric and Mk2 coach objects) are now fairly typical, where around 11-14 fps was a typical range before. Framerates are higher when in the cab view, of course. Certain extremely detailed areas which still need to be simplified for openBVE 1&#8217;s renderer, like the Bourne End and New Ledburn Junctions, as well as Tring and Bletchley, are now handled much better as well (10-12 fps rather than 4-6 fps as it was before, with framerates recovering to normal levels after passing through these isolated locations). To put this in perspective, the route loads around 2600 objects of all types with over 72600 .Freeobj commands, which is <em>a lot<\/em> more than usually found in a BVE route, and this is over a 106 km distance (in comparison, Cross-City South v1.31 loads around 700 objects of all types, with around 5600 .Freeobj commands over around a 25 km distance). In BVE 4, the framerate may be comparable initially, but if I start driving from Watford Junction, it stutters frequently, and BVE 4&#8217;s renderer gives up after reaching Kings Langley just a few kilometres into the route, and BVE 4 crashes without even an error message shortly after; WJ-R is a long way past being suitable for BVE 4 now, hence an awful lot of stuff will need to be removed in the BVE Trainsim versions of the route.<\/p>\n<p>These latest openBVE optimisations which give rise to improvements in framerates, may also mean that route loading times increase a little as the object geometry is optimised, although in practice, I&#8217;m finding that only 5-6 seconds are added to Cross-City South v1.4 \/ new class 323 loading times, and 9 seconds added to Watford Junction to Rugby&#8217;s loading time, bringing the total loading time to 39 seconds for the latter route. Nevertheless, if this is a problem for you, please read <span style=\"white-space: nowrap;\"><a href=\"http:\/\/openbve.freeforums.org\/how-to-reduce-loading-times-at-the-expense-of-performance-t917.html\" target=\"_blank\" rel=\"noopener\">\u00bb this thread \u00ab<\/a><\/span> for information about the hidden options which enable you to limit what the new object optimiser does, allowing for faster loading times, but naturally at the expense of in-game performance.<\/p>\n<p>If you&#8217;re interested in how these performance improvements have been implemented, take a look at <span style=\"white-space: nowrap;\"><a href=\"http:\/\/openbve.trainsimcentral.co.uk\/blog\/\" target=\"_blank\" rel=\"noopener\">\u00bb michelle&#8217;s blog \u00ab<\/a><\/span> where the relevant OpenGL concepts are discussed (the May and June 2009 pages). Essentially, OpenGL&#8217;s GL_TRIANGLE_STRIP and GL_QUAD_STRIP structures are now used along with GL_POLYGON structures which were used exclusively in prior versions of openBVE, and using these structures where possible means that fewer vertices need to be transmitted to the rendering pipeline (due to there being fewer effectively duplicated vertices), thereby improving performance. These other structures are generated automatically by the new object optimiser included in v1.0.7, which was written for openBVE 2&#8217;s engine but has been added to openBVE 1. Version 2 of openBVE should deliver even greater performance improvements however, thanks to the use of <em>display lists<\/em> rather than the <em>immediate mode<\/em> currently used.<\/p>\n<p>This early performance improvement also means that I can capture some higher resolution video of Watford Junction to Rugby now, so come back soon as I&#8217;m preparing another of my YouTube videos, in which I&#8217;ll also show a couple of other things I&#8217;ve been working on. \ud83d\ude42<\/p>\n<table style=\"width: 100%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td align=\"center\"><img loading=\"lazy\" decoding=\"async\" style=\"padding-top: 15px;\" src=\"\/interface\/themes\/modern\/dividers\/divider.gif\" alt=\"Horizontal Rule\" width=\"50\" height=\"2\" \/><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong><span style=\"text-decoration: underline;\">New Object Development Features<\/span><\/strong><\/p>\n<p>Two new features have been added which allow developers greater flexibility and functionality where object creation is concerned &#8212; the <tt>Shear<\/tt> \/ <tt>ShearAll<\/tt> commands, and the ability to specify <strong><em>vertex normals<\/em><\/strong> in B3D and CSV objects (previously, vertex normals could only be specified in .X objects, which were awkward to hand edit). Before experimenting, please make sure that you&#8217;ve downloaded the latest versions of <span style=\"white-space: nowrap;\"><a href=\"http:\/\/openbve.trainsimcentral.co.uk\/downloads.html\" target=\"_blank\" rel=\"noopener\">\u00bb openBVE\u00ab<\/a><\/span>, <span style=\"white-space: nowrap;\"><a href=\"http:\/\/openbve.trainsimcentral.co.uk\/develop\/tool_objectviewer.html\" target=\"_blank\" rel=\"noopener\">\u00bb Object Viewer \u00ab<\/a><\/span> and <span style=\"white-space: nowrap;\"><a href=\"http:\/\/openbve.trainsimcentral.co.uk\/develop\/tool_routeviewer.html\" target=\"_blank\" rel=\"noopener\">\u00bb Route Viewer \u00ab<\/a><\/span> (if necessary, clear your browser cache first to ensure you aren&#8217;t just getting older versions of the downloads from your hard disk cache instead of the webserver).<\/p>\n<p><strong>Shear and ShearAll<\/strong><\/p>\n<p>Using the <tt>Shear<\/tt> \/ <tt>ShearAll<\/tt> commands, we can now skew meshes or entire objects, which makes certain kinds of objects much quicker and easier to create. Take a bridge which crosses a railway at an angle for example; designing the bridge object such that it&#8217;s perpendicular to the railway is relatively easy, but creating it at an angle can be more time consuming, especially if the bridge includes an arch. Using the new commands, we can create the bridge in a perpendicular fashion, and then easily perform a shear mapping operation on all the vertices in either a MeshBuilder block or the entire object:<\/p>\n<table style=\"width: 100%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td align=\"center\"><a class=\"imglink\" href=\"\/images\/openbve_skew_1.png\"><img loading=\"lazy\" decoding=\"async\" style=\"padding: 0px;\" title=\"Original bridge object, perpendicular to rail--click to enlarge\" src=\"\/images\/thumbnails\/openbve_skew_1.png\" alt=\"Original bridge object, perpendicular to rail--click to enlarge\" width=\"200\" height=\"130\" \/><\/a><a class=\"imglink\" href=\"\/images\/openbve_skew_1a.png\"> <img loading=\"lazy\" decoding=\"async\" style=\"padding: 0px;\" title=\"Original bridge object, sheared to the right--click to enlarge\" src=\"\/images\/thumbnails\/openbve_skew_1a.png\" alt=\"Original bridge object, sheared to the right--click to enlarge\" width=\"200\" height=\"130\" \/><\/a><a class=\"imglink\" href=\"\/images\/openbve_skew_1b.png\"> <img loading=\"lazy\" decoding=\"async\" style=\"padding: 0px;\" title=\"Original bridge object, sheared to the left--click to enlarge\" src=\"\/images\/thumbnails\/openbve_skew_1b.png\" alt=\"Original bridge object, sheared to the left--click to enlarge\" width=\"200\" height=\"130\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>These results are created with the following commands added right at the <span style=\"text-decoration: underline;\">end<\/span> of the object file:<\/p>\n<table style=\"width: 400px;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td><img loading=\"lazy\" decoding=\"async\" src=\"\/interface\/table_spacer_trans.gif\" alt=\"\" width=\"20\" height=\"1\" \/><\/td>\n<td>\n<div class=\"codebox\" style=\"width: 425px\">\nShearAll, 0, 0, 1, 1, 0, 0, 0.75\n<\/div>\n<p>or&#8230;<\/p>\n<div class=\"codebox\" style=\"width: 425px\">\nShearAll, 0, 0, 1, 1, 0, 0, -0.75\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Please see the relevant openBVE documentation <span style=\"white-space: nowrap;\"><a href=\"http:\/\/openbve.trainsimcentral.co.uk\/develop\/object_csv.html#shear\" target=\"_blank\" rel=\"noopener\">\u00bb here \u00ab<\/a><span> for more information about these commands and the parameters.<\/span><\/span><\/p>\n<p><strong>Vertex Normals<\/strong><\/p>\n<p>If you&#8217;ve used the Cylinder command in your objects, you&#8217;ll probably have noticed that the resulting collection of faces were smoothly shaded. Creating any other mesh however, resulted in flat shading. If the object was converted to the .X format, it was possible to manually hand edit the vertex normals to smoothly shade faces, but due to the nature of the format this wasn&#8217;t user friendly, and wasn&#8217;t possible at all in B3D or CSV format objects. Now though, what I think is an easy way to apply vertex normals and smooth shading to meshes has been implemented. Take the following screenshots:<\/p>\n<table style=\"width: 100%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td align=\"center\"><a class=\"imglink\" href=\"\/images\/openbve_normals_1.png\"><img loading=\"lazy\" decoding=\"async\" style=\"padding: 0px;\" title=\"Standard mesh--click to enlarge\" src=\"\/images\/thumbnails\/openbve_normals_1.png\" alt=\"Standard mesh--click to enlarge\" width=\"200\" height=\"130\" \/><\/a><a class=\"imglink\" href=\"\/images\/openbve_normals_1a.png\"> <img loading=\"lazy\" decoding=\"async\" style=\"padding: 0px;\" title=\"Standard mesh with vertex normals specified--click to enlarge\" src=\"\/images\/thumbnails\/openbve_normals_1a.png\" alt=\"Standard mesh with vertex normals specified--click to enlarge\" width=\"200\" height=\"130\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>On the left, we have a simple mesh with 8 vertices and 3 faces:<\/p>\n<table style=\"width: 100%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td><img loading=\"lazy\" decoding=\"async\" src=\"\/interface\/table_spacer_trans.gif\" alt=\"\" width=\"20\" height=\"1\" \/><\/td>\n<td>\n<div class=\"codebox\" style=\"width: 425px\">\nCreateMeshBuilder<br \/>\nAddVertex, 3, 0, 1, <span style=\"color: #888888;\">;vertex 0<\/span><br \/>\nAddVertex, 3, 0,-1, <span style=\"color: #888888;\">;vertex 1<\/span><br \/>\nAddVertex, 1, 1, 1, <span style=\"color: #888888;\">;vertex 2<\/span><br \/>\nAddVertex, 1, 1,-1, <span style=\"color: #888888;\">;vertex 3<\/span><br \/>\nAddVertex,-1, 1, 1, <span style=\"color: #888888;\">;vertex 4<\/span><br \/>\nAddVertex,-1, 1,-1, <span style=\"color: #888888;\">;vertex 5<\/span><br \/>\nAddVertex,-3, 0, 1, <span style=\"color: #888888;\">;vertex 6<\/span><br \/>\nAddVertex,-3, 0,-1, <span style=\"color: #888888;\">;vertex 7<\/span><br \/>\nAddFace,0,1,3,2<br \/>\nAddFace,2,3,5,4<br \/>\nAddFace,4,5,7,6<br \/>\nSetColor,190,160,160\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>On the right, we have the same mesh, but with <strong><span style=\"color: rgb(50, 215, 150);\">vertex normals<\/span><\/strong> specified, resulting in the smoothly shaded appearance:<\/p>\n<table style=\"width: 100%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td><img loading=\"lazy\" decoding=\"async\" src=\"\/interface\/table_spacer_trans.gif\" alt=\"\" width=\"20\" height=\"1\" \/><\/td>\n<td>\n<div class=\"codebox\" style=\"width: 425px\">\nCreateMeshBuilder<br \/>\nAddVertex, 3, 0, 1, <strong><span style=\"color: rgb(50, 215, 150);\">0.6, 1, 0<\/span><\/strong><br \/>\nAddVertex, 3, 0,-1, <strong><span style=\"color: rgb(50, 215, 150);\">0.6, 1, 0<\/span><\/strong><br \/>\nAddVertex, 1, 1, 1, <strong><span style=\"color: rgb(50, 215, 150);\">0.3, 1, 0<\/span><\/strong><br \/>\nAddVertex, 1, 1,-1, <strong><span style=\"color: rgb(50, 215, 150);\">0.3, 1, 0<\/span><\/strong><br \/>\nAddVertex,-1, 1, 1,<strong><span style=\"color: rgb(50, 215, 150);\">-0.3, 1, 0<\/span><\/strong><br \/>\nAddVertex,-1, 1,-1,<strong><span style=\"color: rgb(50, 215, 150);\">-0.3, 1, 0<\/span><\/strong><br \/>\nAddVertex,-3, 0, 1,<strong><span style=\"color: rgb(50, 215, 150);\">-0.6, 1, 0<\/span><\/strong><br \/>\nAddVertex,-3, 0,-1,<strong><span style=\"color: rgb(50, 215, 150);\">-0.6, 1, 0<\/span><\/strong><br \/>\nAddFace,0,1,3,2<br \/>\nAddFace,2,3,5,4<br \/>\nAddFace,4,5,7,6<br \/>\nSetColor,190,160,160\n<\/div>\n<\/table>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>In the first annotated Object Viewer screenshot, you can see that the automatically generated normals are depicted via the vector lines emanating from the vertices (you can view these by pressing the N key within Object Viewer). Note also the flat shading, and how this relates to the direction of the normal vectors. In the second screenshot however, which shows the same mesh with manually defined normals, smooth shading is now applied, and vertices 2, 3, 4 and 5 now have one normal vector each, affecting all faces that share those vertices. You can see that each normal vector is created relative to the associated vertex coordinates.<\/p>\n<p>To give some examples of where to use this feature, the ability specify normals allows me to, for example, reduce the number of faces on a curved surface to improve performance in some circumstances, or smoothly shade the grass embankments shown in the bridge screenshots above, or the curved surfaces of locomotives and rolling stock:<\/p>\n<table style=\"width: 100%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td align=\"center\"><a class=\"imglink\" href=\"\/images\/openbve_normals_2.png\"><img loading=\"lazy\" decoding=\"async\" style=\"padding: 0px;\" title=\"Original object with automatically generated normals--click to enlarge\" src=\"\/images\/thumbnails\/openbve_normals_2.png\" alt=\"Original object with automatically generated normals--click to enlarge\" width=\"200\" height=\"130\" \/><\/a><a class=\"imglink\" href=\"\/images\/openbve_normals_2a.png\"> <img loading=\"lazy\" decoding=\"async\" style=\"padding: 0px;\" title=\"Object with vertex normals specified--click to enlarge\" src=\"\/images\/thumbnails\/openbve_normals_2a.png\" alt=\"Object with vertex normals specified--click to enlarge\" width=\"200\" height=\"130\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table style=\"width: 100%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td align=\"center\"><a class=\"imglink\" href=\"\/images\/openbve_normals_2b.png\"><img loading=\"lazy\" decoding=\"async\" style=\"padding-right: 0px; padding-left: 0px; padding-bottom: 0px; padding-top: 20px;\" title=\"Original object with automatically generated normals--click to enlarge\" src=\"\/images\/thumbnails\/openbve_normals_2b.png\" alt=\"Original object with automatically generated normals--click to enlarge\" width=\"200\" height=\"130\" \/><\/a><a class=\"imglink\" href=\"\/images\/openbve_normals_2c.png\"> <img loading=\"lazy\" decoding=\"async\" style=\"padding-right: 0px; padding-left: 0px; padding-bottom: 0px; padding-top: 20px;\" title=\"Original object with automatically generated normals--click to enlarge\" src=\"\/images\/thumbnails\/openbve_normals_2c.png\" alt=\"Original object with automatically generated normals--click to enlarge\" width=\"200\" height=\"130\" \/><\/a><br \/>\n<a class=\"imglink\" href=\"\/images\/openbve_normals_2d.png\"><img loading=\"lazy\" decoding=\"async\" style=\"padding: 0px;\" title=\"Object with vertex normals specified--click to enlarge\" src=\"\/images\/thumbnails\/openbve_normals_2d.png\" alt=\"Object with vertex normals specified--click to enlarge\" width=\"200\" height=\"130\" \/><\/a><a class=\"imglink\" href=\"\/images\/openbve_normals_2e.png\"> <img loading=\"lazy\" decoding=\"async\" style=\"padding: 0px;\" title=\"Object with vertex normals specified--click to enlarge\" src=\"\/images\/thumbnails\/openbve_normals_2e.png\" alt=\"Object with vertex normals specified--click to enlarge\" width=\"200\" height=\"130\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table style=\"width: 100%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td align=\"center\"><img loading=\"lazy\" decoding=\"async\" style=\"padding-top: 15px;\" src=\"\/interface\/themes\/modern\/dividers\/divider.gif\" alt=\"Horizontal Rule\" width=\"50\" height=\"2\" \/><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Finally, for the more technically minded amongst us, openBVE&#8217;s debug output layout (viewable via the F10 key) has been revamped and contains some interesting extra data relating to the number of each different face type in use:<\/p>\n<table style=\"width: 100%;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td align=\"center\"><img loading=\"lazy\" decoding=\"async\" style=\"padding: 0px;\" title=\"openBVE v1.0.7.1 debug output\" src=\"\/images\/openbve_debug_1.png\" alt=\"openBVE v1.0.7.1 debug output\" width=\"600\" height=\"390\" \/><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>openBVE v1.0.7.1 is now available; I&#8217;d recommend heading over to the \u00bb openBVE homepage \u00ab to download the latest stable release, and don&#8217;t forget to read the \u00bb Changelog \u00ab for a full list of alterations and new features. Update (18th June): openBVE v1.0.7.2 was released yesterday. This version includes a bugfix relating to problems [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[8,10,11,15,21],"class_list":["post-882","post","type-post","status-publish","format-standard","hentry","category-openbve","tag-cross-city-south","tag-hardware","tag-openbve","tag-screenshots","tag-watford-jn-to-rugby"],"_links":{"self":[{"href":"https:\/\/railsimroutes.net\/blog\/wp-json\/wp\/v2\/posts\/882","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/railsimroutes.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/railsimroutes.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/railsimroutes.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/railsimroutes.net\/blog\/wp-json\/wp\/v2\/comments?post=882"}],"version-history":[{"count":0,"href":"https:\/\/railsimroutes.net\/blog\/wp-json\/wp\/v2\/posts\/882\/revisions"}],"wp:attachment":[{"href":"https:\/\/railsimroutes.net\/blog\/wp-json\/wp\/v2\/media?parent=882"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/railsimroutes.net\/blog\/wp-json\/wp\/v2\/categories?post=882"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/railsimroutes.net\/blog\/wp-json\/wp\/v2\/tags?post=882"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}