Hard Light Productions Forums
Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Rampage on December 04, 2011, 11:05:30 pm
-
Hello FSO Team,
Greetings from the Inferno Team. We have encountered an issue where the game would crash when using too many (~180) HUD shield icon entries. Is there a limit to how many shield icons allowed? If so, then is there a way to bypass that limit (feature request)? Thanks for your consideration.
Humbly,
Rampage
INFTeam
-
The current limit appears to be 80 (yes, 80, not 180). It should be fairly easy to bump to ~200, but this limit at 80 has stood for more than 8 years. What exactly are HUD Shield Icons and why do you need so many?
-
That's the little icon on your hud that displays a top-down view of a ship with its shield quadrants and their strength. We need 'em because we've got four species worth of shielded craft with the potential to add more to each. Could this no be made dynamic like so many other limits?
-
It'll be awesome if it could be bumped.
R
-
That means you have more than 20 (45 at the level you are running into issues at) shielded ships per faction? Or is there something else going on that I have missed?
Dynamic is decidedly less easy. More than ~200 (dynamic or not) makes it more difficult as well. I am trying to quantify what requires this many because it appears from my quick dive in the code last night that this is basically one per ship which means the absolute max for these icons would be 250 (the ship class limit).
-
That's the little icon on your hud that displays a top-down view of a ship with its shield quadrants and their strength. We need 'em because we've got four species worth of shielded craft with the potential to add more to each. Could this no be made dynamic like so many other limits?
where you have bitmaps you are opening another can of worms as far as making the system dynamic goes. more icons means less slots available for other bitmaps (like textures). a hud icon is 5 frames iirc, so it would use up 5 texture slots each. i very much doubt bumping the texture limit is on the table, but still bumping the shield icon limit a little probably wouldn't hurt. 80 seems kinda low to me.
would it be possible to come up with a better procedural shield?
-
That's the little icon on your hud that displays a top-down view of a ship with its shield quadrants and their strength. We need 'em because we've got four species worth of shielded craft with the potential to add more to each. Could this no be made dynamic like so many other limits?
where you have bitmaps you are opening another can of worms as far as making the system dynamic goes. more icons means less slots available for other bitmaps (like textures). a hud icon is 5 frames iirc, so it would use up 5 texture slots each. i very much doubt bumping the texture limit is on the table, but still bumping the shield icon limit a little probably wouldn't hurt. 80 seems kinda low to me.
would it be possible to come up with a better procedural shield?
I would much prefer this, how about a table option somewhere to switch between the current square shield icons and a round one when using the "generate icon" flag.
If you could add X,Y scaling to "generate icon" I would love you forever.
-
those square icons are horrible. i tried to make a 3d shield icon for my own cockpit but never got it to work. but i have an idea for how to draw a shield icon in 2d with only a base image of the ship.
(http://i213.photobucket.com/albums/cc103/Emperor_of_Nihil/shieldiconalgorithm.jpg)
1: first you render the ship (i used an actual image from an icon to save time) centered on the image and taking up a square equivalent to 1/4 the total area of the image anc centered in the middle.
2: then you divide the image into quadrants.
3: iterate through the pixels in each quadrant along the edge and scanning towards the center until the first non-black pixel is encountered.
4: do the same for the remaining quadrants until you have 4 points to create a polygon.
5: copy the polygon and mirror it down the middle
6: re sequence the points of both polygons into one polygon
7: use an algorithm to convert the straight lines to curves, using the length and angle of the lines relative to each-other as input.
8: once you have a rounded source polygon enlarge it (175% here) to create an outer boundary. you only need to do this and all previous steps once for each shield icon at game start.
9: create a line between the top-left corner and the image center and trace it to find the point of intersection between it and the big and small polygons to create 2 points in 2d space. draw a gradient line between them. rotate the line a bit and repeat, do this until the entire image is circled. as you begin drawing each quadrant, set a different brightness based on the shield strength for that quadrant.
10: an example of different brightness levels representing different shield strength. (also using some blur here to improve the quality)
i drew the example in photoshop, so any flaws are because of that. im also not sure how fast this would be. perhaps it would be possible to do this with a shader applied to a source texture (a one time rtt job). this would still use a texture but 1 instead of 5, easing up the demand on bmpman.
*edit*
did not really consider asymmetric ships like the dragon or scorpion. a variation on steps 2-6 would be tweaked a little. split the quadrants down the middle so you have 8 half-quadrants, and scan the pixels from the corner to the split and down towards the image center until a non-black pixel is encountered, so that each quadrant should generate a point. this also simplifies steps 4,5,and 6.
*edit again*
another idea is that you can simplify the maths by using only the inner boundry. when encountered on the center to corner trace draw a gradient line of a set length along the trace vector outwards starting from the intersection. you can also vary the line length with shield integrity and use some ratio of varying thickness and intensity to possibly produce a shield more closely resembling the stock shield icons.
another draw technique involves masking the non-working area and drawing a non-filled polygon at varying scale and brightness to create concentric rings. this might be faster since you dont need to find any polygon-line intersections to draw the effect and use a mask and pixel maths which should be kinda fast-ish.
-
If bumping the limit to 200 is possible without too many problems, then I'd say it should be done. Inferno doesn't have more than 200 shielded craft, that's for sure. After that, we could think of an alternative way of generating the icons. Also, Nuke's idea sounds good to me. Perhaps it could be modified to support a few different styles of icons (WCS and FoTG ones, for instance).
-
If it's going to be bumped why not just bump it to MAX_SHIP_CLASSES so every ship can have one if needed?
-
3: iterate through the pixels in each quadrant along the edge and scanning towards the center until the first non-black pixel is encountered.
4: do the same for the remaining quadrants until you have 4 points to create a polygon.
5: copy the polygon and mirror it down the middle
You can have pointy and asymmetric ships :d. I also believe that solid color or simple shading technique would not look good.
You can never deny beauty of the hand work.
-
3: iterate through the pixels in each quadrant along the edge and scanning towards the center until the first non-black pixel is encountered.
4: do the same for the remaining quadrants until you have 4 points to create a polygon.
5: copy the polygon and mirror it down the middle
You can have pointy and asymmetric ships :d. I also believe that solid color or simple shading technique would not look good.
You can never deny beauty of the hand work.
did not really consider asymmetric ships like the dragon or scorpion. a variation on steps 2-6 would be tweaked a little. split the quadrants down the middle so you have 8 half-quadrants, and scan the pixels from the corner to the split and down towards the image center until a non-black pixel is encountered, so that each quadrant should generate a point. this also simplifies steps 4,5,and 6.
1: read the thread!
2: the color would not be solid nor would it be simple (its only that way because i used an existing icon to create the example to save time), apply shader and it would look awesome. also shield icons are confined to 16 colors, this meathod allows for a colored ship icon and you could make the shield segments any color you want by setting the gradient color. they could also be made dynamically so that they would be scalable with screen resolution. the result is higher quality icons.
3: making shield icons is easy, you make it sound like its hard to do.
the idea is to reduce the number of bitmap slots you need to allocate to shield icons so that you can have more icons. the idea is also to improve the current game-generated icons that are kinda ugly.
you could probably also draw the shield mesh while masking out the ship and other quadrants and vary its opacity from near opaque to completely transparent based on strength to draw a quadrant. this might actually be a lot faster than the way i thought of, and would draw shields as they are in the model. again, shaders would make them look awesome.
-
3: iterate through the pixels in each quadrant along the edge and scanning towards the center until the first non-black pixel is encountered.
4: do the same for the remaining quadrants until you have 4 points to create a polygon.
5: copy the polygon and mirror it down the middle
You can have pointy and asymmetric ships :d. I also believe that solid color or simple shading technique would not look good.
You can never deny beauty of the hand work.
did not really consider asymmetric ships like the dragon or scorpion. a variation on steps 2-6 would be tweaked a little. split the quadrants down the middle so you have 8 half-quadrants, and scan the pixels from the corner to the split and down towards the image center until a non-black pixel is encountered, so that each quadrant should generate a point. this also simplifies steps 4,5,and 6.
1: read the thread!
2: the color would not be solid nor would it be simple (its only that way because i used an existing icon to create the example to save time), apply shader and it would look awesome. also shield icons are confined to 16 colors, this meathod allows for a colored ship icon and you could make the shield segments any color you want by setting the gradient color. they could also be made dynamically so that they would be scalable with screen resolution. the result is higher quality icons.
3: making shield icons is easy, you make it sound like its hard to do.
the idea is to reduce the number of bitmap slots you need to allocate to shield icons so that you can have more icons. the idea is also to improve the current game-generated icons that are kinda ugly.
you could probably also draw the shield mesh while masking out the ship and other quadrants and vary its opacity from near opaque to completely transparent based on strength to draw a quadrant. this might actually be a lot faster than the way i thought of, and would draw shields as they are in the model. again, shaders would make them look awesome.
Also With the right code adjustments it could be used in conjunction with different shield segment numbers without needing to hand draw a new shield icon
-
like 32 segment capship shields :D
-
Well i did write support for 1 and 2 segment shields but it is not in the trunk - that is the game side support, not anything related to icons
-
We had 2 segment shield icons to go along with that code at one point.
-
Well i did write support for 1 and 2 segment shields but it is not in the trunk - that is the game side support, not anything related to icons
Is there any chance it'd make it into the trunk? FoTG, Fringespace, WCS mods (WC1, 2 and WCP era) and maybe some others could really use duant shields, and a nonsegmented shield would also have it's uses.
-
I really like nuke's idea. Dunno how feasible code-wise it is, but it looks simple enough, and having the option for a procedural shield icon seems like a smart thing to have.
Ideally we'd be able to choose between the "auto-generated" shield icon or a "handmade" icon; "handmade" would probably be the method of choice for asymmetric or pointy ships, while rather well-behaved vessels could be handled with the "auto-generate" function.
-
im sure that asymmetrical ships can be handled correctly by changing your shape determining code. there are probably a bunch of algorithms you can use. get valathil in here he probably knows a better way to do it.
-
I might argue that code for procedural 2D shield icons would require additional processing, more so than the conventional method already implemented. Thus, when you have a program getting progressively more taxed that runs on a single core...
But this might be unjustified. My thoughts are this: The ship's top down view will have full opacity factor, apart from any typical FS HUD opacity. It is thus a "solid" bitmap with a background of... zero opacity! If it is possible to write a code that can draw four quadrants with vairable strength gradients that doesn't take up too much processing power, then you might have a winner.
The code would need to do the following:
- Find the center of the bitmap. Very simple mathematics here, just divide the resolution by two on both the x- and y-axis of the bitmap, and place the center coordinates there.
- From this point, quadrant vectors are drawn at 45 degree angles from forward, at 90 degree separation. Or you could make an angular spacing function based on bitmap resolution.
- The absent background opacity is detected by the code, and a shield "gradient" is drawn from the ship's central coordinate. The start of the quadrant image is drawn a pre-determined distance from the full-opacity ship icon, and extends to an appropriately determined length.
Thus, any ship icon, asymmetric or not, could be drawn with a shield. That is, if you could code it, and it would not use more resources than necessary.
-
I might argue that code for procedural 2D shield icons would require additional processing, more so than the conventional method already implemented. Thus, when you have a program getting progressively more taxed that runs on a single core...
But this might be unjustified. My thoughts are this: The ship's top down view will have full opacity factor, apart from any typical FS HUD opacity. It is thus a "solid" bitmap with a background of... zero opacity! If it is possible to write a code that can draw four quadrants with vairable strength gradients that doesn't take up too much processing power, then you might have a winner.
The code would need to do the following:
- Find the center of the bitmap. Very simple mathematics here, just divide the resolution by two on both the x- and y-axis of the bitmap, and place the center coordinates there.
- From this point, quadrant vectors are drawn at 45 degree angles from forward, at 90 degree separation. Or you could make an angular spacing function based on bitmap resolution.
- The absent background opacity is detected by the code, and a shield "gradient" is drawn from the ship's central coordinate. The start of the quadrant image is drawn a pre-determined distance from the full-opacity ship icon, and extends to an appropriately determined length.
Thus, any ship icon, asymmetric or not, could be drawn with a shield. That is, if you could code it, and it would not use more resources than necessary.
its more of a memory vs c/gpu cycles tradeoff. whats more important, cycles, or texture memory? even then the game is dealing with hundreds of models, hundreds of thousands of polygons, hundreds of megs of bitmaps, i dont think rendering a little 256^2 icon is going to matter much for performance. i dont think these icons, procedural or not, tax the game all that much.
if you can draw an opaque pixel, you can draw a transparent one too. thats trivial. if you want to do a simple radial gradient with quadrant masking, thats also fine (an improvement to those box icons), but i think it would look better if you could conform the shield to the shape to the ship, and i can think of a dozen rendering methods to do that.
-
Well, but the point is, why keep rerendering this stuff every frame when you can do it once during mission load and cache the results?
-
you could do it that way. you can then use a higher quality generation routine, and then draw with variable opacity, of course that kinda still uses up bitmap slots.
-
Sure, but so do bitmap icons. Not much of a difference there, I think.
-
I must admit to being a layman when it comes to bitman and how it works so something like this might already be in play or impossible but seeing as we are generating the icons at mission start can we store the generated icons in a kind of image array, basically a big single layer image with all the permutation of each ship icon in a row, then under that the same for the next ship and so on. If it would work a file storing 4 would cut the number of bitman slots used by shield icons down by a quarter and so on.
If you clamp the generation code to use a set pixel dimension, say 32x32 then the code would be able to assign to the ship class the file name the icon is stored in and the row say Shields2 row 3. because the icons are a uniform size the game would know that if it goes down to pixel row 96 that is the start of the shield icons for that ship class.
-
Well, but the point is, why keep rerendering this stuff every frame when you can do it once during mission load and cache the results?
What about glowpoints/animations? Are those reflected in the generated shield "icon" ?
-
Seeing as the icon is a five frame ANI... no.
-
Seeing as the icon is a five frame ANI... no.
Well, but the point is, why keep rerendering this stuff every frame when you can do it once during mission load and cache the results?
Is it even an ANI?
And I remember seeing blinking lights on something... it might have been something with 3d ship select, though.
-
Right now, they are (Animations, anyway, I don't think glowpoints are rendered there. Or that they are visible enough to register at those sizes).
But there's a problem with that: It's really not efficient. As an extreme example, take "The Blade Itself" from WiH. Go to external camera, and target the other Karuna in the mission. Suddenly, you have four Karunas rendered in realtime on your screen, with all the geometry- and texture uploads that entails. For a model as horrifyingly bad as the Karuna, this is a performance concern.
Now, granted, that is an extreme case, and it's not really all that relevant during normal gameplay. But as I see it, this is more about improving the look of the default shield icons the engine creates, which is pretty ugly. And, speaking for myself, I would rather trade a bit more memory usage for speed any day, thus my recommendation to render them once and store the results.
Seeing as the icon is a five frame ANI... no.
Well, but the point is, why keep rerendering this stuff every frame when you can do it once during mission load and cache the results?
Is it even an ANI?
And I remember seeing blinking lights on something... it might have been something with 3d ship select, though.
sigtau, plz to read thread. This is about the icons the engine generates when there is no icon specified in the tbl. These consist of 4 shield brackets, and a live rendering of the model. I'd rather take a little bit of time and render the 5 frames a normal shield ani has during mission load than having to rerender all of this stuff every frame.
-
i have nothing against the generate and cache mentality, because it solves the problem nicely and has the added bonus of being scalable to match the screen resolution, so you still get some benefits over traditional icons. you just dont save any texture slots.