Page 7 of 11

Re: New widget: Enemy Spotter

Posted: 17 Dec 2009, 07:37
by Niobium
TradeMark wrote:rofl, he just keeps posting his results with no evidence at all. gj man
I copied & renamed my modified teamplatters widget. And replaced the 1 display list call for polygons with 1 display list call for texture quad. Which I believe is more of a valid test of texture vs polygon than comparing two DIFFERENT widgets, as VBS did. But feel free to use his result to declare yourself the winner if you want to look stupid.

Re: New widget: Enemy Spotter

Posted: 17 Dec 2009, 07:45
by Argh
Again, I want to emphasize that my version isn't just apples-to-apples: people said they wanted to see the real TC, so I put that in.

And I screwed up with the placement of that darn glTexture callout. Bad coder! Bad!

It would probably be wisest to release your modified version of this, or I'll just do a cleanup of TradeMark's when I get a chance.

Re: New widget: Enemy Spotter

Posted: 17 Dec 2009, 07:54
by Niobium
Argh wrote:It would probably be wisest to release your modified version of this, or I'll just do a cleanup of TradeMark's when I get a chance.
Your texture quad code + global visible units table + radius table + basic optimization = my widget. Basically. It's nothing fancy.

Re: New widget: Enemy Spotter

Posted: 17 Dec 2009, 08:50
by Argh
Here ya go: apples vs. apples. Except I use RED, not BLUE, as the stock color. Hehe.

Code: Select all

function widget:GetInfo()
   return {
      name      = "Enemy Spotter v.2",
      desc      = "Draws smoothed octagon under enemy units",
      author    = "Argh,TradeMark,Trepan",
      date      = "December 17th, 2009",
      license   = "(C) WolfeGames, released under GNU GPL, v2 or later",
      layer     = 5,
      enabled   = false  --  loaded by default?
   }
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

-- Automatically generated local definitions

local glBeginEnd             = gl.BeginEnd
local glTexCoord =	gl.TexCoord
local glTexture = gl.Texture
local GL_QUADS = GL.QUADS
local glColor                = gl.Color
local glCreateList           = gl.CreateList
local glDeleteList           = gl.DeleteList
local glDepthTest            = gl.DepthTest
local glDrawListAtUnit       = gl.DrawListAtUnit
local glVertex               = gl.Vertex
local GetVisibleUnits     = Spring.GetVisibleUnits
local spGetUnitDefID         = Spring.GetUnitDefID
local spGetUnitTeam          = Spring.GetUnitTeam

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local LocalTeam = Spring.GetLocalTeamID()
local ENEMY_UNITS       = Spring.ENEMY_UNITS
local texture = "bitmaps/StaticCircle.tga"
local radiusDefs = {}

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

function widget:Initialize()
	for uDefID, uDef in pairs(UnitDefs) do
		radiusDefs[uDefID] = uDef.radius * 1.25
	end

	SimpleCircle = glCreateList(function()
		glBeginEnd(GL_QUADS, function()
			glTexCoord(0.04,0.04)
			glVertex(-1,10,-1)
			glTexCoord(0.96,0.04)
			glVertex(1,10,-1)
			glTexCoord(0.96,0.96)
			glVertex(1,10,1)
			glTexCoord(0.04,0.96)
			glVertex(-1,10,1)
		end)
	end)
end

function widget:Shutdown()
	glDeleteList(SimpleCircle)
end


function widget:DrawWorldPreUnit()
	glDepthTest(true)
	glTexture(texture)
	glColor(1.0,0,0,1.0)
	local teamID, ud
	local visible = GetVisibleUnits(ENEMY_UNITS, nil, false)

	for i = 1,#visible do
		unitID = visible[i]
		teamID = spGetUnitTeam(unitID)
		if teamID ~= LocalTeam then
			ud = spGetUnitDefID(unitID)
			radius = radiusDefs[ud]
			glDrawListAtUnit(unitID, SimpleCircle, false, radius, 1.0, radius, 0, 0, 0, 0)
		end
	end
	glTexture(false)
end
With fixes from jK.

Re: New widget: Enemy Spotter

Posted: 17 Dec 2009, 08:52
by manolo_
cmon please stop this beef and open a new thread about how to optimize widgets

Re: New widget: Enemy Spotter

Posted: 17 Dec 2009, 13:45
by TradeMark
Argh wrote:In testing over here, mine runs fast enough that I really just don't see much of a difference in total load while it's operating, so I think it's fair to say it's "fast".
yeah i said exactly same to you few pages ago :|

tho, i still dont prefer any texture, since its not needed really

try to make same smoothed circle with textures... you need like 512x512 image for it

Re: New widget: Enemy Spotter

Posted: 17 Dec 2009, 13:58
by Argh
No, you can use a pretty small circle- 128, 256 at max. If it's just supposed to be a blurry glow like that, it'll be fine at normal distances. The main reason to use textures is to have some flexibility, though- the one in P.U.R.E. uses quite a few more of them, so that if it's a plain circle, it's a building, glow without facing, it's a soldier or mech, and so forth.

If you aren't a doofus, like I was, and reloading that texture constantly, it's pretty cheap.

Re: New widget: Enemy Spotter

Posted: 17 Dec 2009, 14:05
by TradeMark
yeah try to make a krogoth... or juggernaut, they have pretty big circles

you could do all those simple geometric shapes without textures too

as a game designed, you probably know that it looks fugly when you see pixels (or blurred pixels) on something like that when you zoom in...

Re: New widget: Enemy Spotter

Posted: 17 Dec 2009, 14:07
by Argh
Nah, it's actually fine, up until HUGE stuff. Like, IDK, maybe 12X12 on a side, then it's obviously pixelated.

And making those shapes with polygons... meh, to keep it smooth, that's expensive, once it's not small. It's better to cheat, up until you need a 512 texture, imo. But I've never had to use one that big, on anything in P.U.R.E.- 256s were fine.

And sure, it's ugly, if you get to screenshot range. Heck, then it's obvious that it's a quad slicing right through stuff. So I just turn it off. But from overhead, typical distances? It's fine.

Meh, here's a screenshot. This is pretty zoomed-in- these guys are filling most of the screen (the original shot was 860 pixels wide):

Image

Re: New widget: Enemy Spotter

Posted: 17 Dec 2009, 14:18
by TradeMark
my octagon shape is enough, i cant even see its octagon, looks like circle to me (because i faded the edges so much), unless i really try to look at the shape... but who the fuck cares is it perfect circle or almost circle?

Edit: isnt that like 256x256 texture there? try to fill it with same way as i do, and look how your FPS goes down...

Re: New widget: Enemy Spotter

Posted: 17 Dec 2009, 14:22
by Argh
Well, sure, for the fade it's OK- I think that works just fine.

But for a circle like that? It'll look really faceted. Whether people care or not... meh, IDK, some people find it crude, some don't care.

And yeah... that's why I'm using a texture for that. I'm cheating. It just has to look like a circle, and be cheap. Not be a circle. Just saying, it works, up until really fricking huge stuff. And that could be a triangle with tiny dots, multiple colors, whatever. I am thinking that I need to rewrite the one for P.U.R.E. now, use a shader, make it dynamically alter over time, hehe.

Re: New widget: Enemy Spotter

Posted: 17 Dec 2009, 14:25
by TradeMark
i know, i didnt want ring like that

Re: New widget: Enemy Spotter

Posted: 17 Dec 2009, 14:31
by Argh
Well, here's a glow, using a 64X64- it's just a simple circular gradient, nothing special. Looks all right. Would want to use 128 for really big stuff (this robot's 5X5 in World Builder, not as small as in CA):

Image

Re: New widget: Enemy Spotter

Posted: 17 Dec 2009, 14:36
by TradeMark
why those circles are so small? if that was BA those circles would be 2x bigger in diameter...

try to make it look like my smooth shape

edit: made texture for you:
Image

color = alpha and color

Re: New widget: Enemy Spotter

Posted: 17 Dec 2009, 14:44
by Argh
I can make them bigger, if you want. In that source I posted, that's controlled here, btw:

Code: Select all

radiusDefs[uDefID] = uDef.radius * 1.25
Utterly non-fancy, could be made a lot fancier. That's probably fine for most 3DOs. Personally, I'd rather define it per unit with a customParam.

Image

And sure, I'll be happy to test with the donut.

Re: New widget: Enemy Spotter

Posted: 17 Dec 2009, 14:51
by TradeMark
Argh wrote:I can make them bigger, if you want. In that source I posted, that's controlled here, btw:

Code: Select all

radiusDefs[uDefID] = uDef.radius * 1.25
oh yeah i forgot, so my total "texture" size would be 1.5*1.75 = 2.625 compared to unit radius

Re: New widget: Enemy Spotter

Posted: 17 Dec 2009, 14:54
by Argh
Hmm. Needs a narrower donut, wider pure white, with less glow, imo. I did a quick-fix with curves, but this isn't quite right. And yeah, I'll use 2.6, used 2.25 here but the circle shrank a lot when I used Curves.

Image

Re: New widget: Enemy Spotter

Posted: 17 Dec 2009, 14:59
by TradeMark
hmm... looks really weird... :D not at all like my version :(

dont edit the pic i sent you

actually my pic is totally wrong, outer fade should be larger etc...

Re: New widget: Enemy Spotter

Posted: 17 Dec 2009, 15:03
by Argh
Yeah, yours was just kind've a blurry glow, not a whole lot different than that first one I did. You couldn't see any ring around the units at all. Then I fixed that with Curves, but it was like half the size it needed to be.

Here, made the ring narrower, so that it's clearly a ring. 2.6 looks too big to me, tho. That can get fixed at the end, though.
Image

Re: New widget: Enemy Spotter

Posted: 17 Dec 2009, 15:06
by TradeMark
try this
Image

Edit: updated the image slightly longer outer fade >_>

also use blue this time, since its much more easier to see the color near the edges...