LOS

LOS

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

LOS

Post by Beherith »

Image
Image
Switch rapidly between images for animgif effect.

So unlike my previous attempt at this, the info texture is plugged into a fog shader.

It adds a dark fog to the out-of-los areas, and static noise to areas not covered by radar.

So there are two possible ways for this to be done:
1. Through the terrain shader (previous attempt)
Pros:
- Faster
- Better looking effects (like desaturation, hue shifts, etc)

Cons:
- Static and hard to modify (because its engine shader, hard to plug new things into it)
- only effects terrain

2. Through a depth shader gadget as shown here
Pros:
- Each mod can easily customize the way it looks
- No significant engine code needed
- Effects everything (map, grass, water surface, features)
- Allows map border fog

Cons:
- Slower
- limited set of effects (basically a transparent image overlay)
- will interact badly with map fog effect
Last edited by Beherith on 20 Apr 2012, 06:29, edited 1 time in total.
Reason: Added more cons
User avatar
Pxtl
Posts: 6112
Joined: 23 Oct 2004, 01:43

Re: LOS

Post by Pxtl »

They're the same.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: LOS

Post by zwzsg »

1 because if it looks good and is fast, mod-makers won't need to write a better one anyway.

2 would be falling into the fallacy of confusing "modders will be able to customize it" with "modders will customize it".
luckywaldo7
Posts: 1398
Joined: 17 Sep 2008, 04:36

Re: LOS

Post by luckywaldo7 »

Wow, I love you so hard right now for making LOS better. :mrgreen:

I wouldn't count out #2 so fast if the first one doesn't work on water (that's what it sounds like anyway). Also, what is the difference in performance like?
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: LOS

Post by PicassoCT »

both.
1 as default
2 as overwrite :D

Conclusion: Do not as the masses! Brutal Dictatorship is the only answer!
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: LOS

Post by Beherith »

Pxtl, fixed the images. I would like to ask Kloot and jK about their thoughts on the matter.

Currently I have added $infotex to gl.Texture, and have an additional unsyncedctrl callin that forces the generation of the los texture even if LOS mode is off.
zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

Re: LOS

Post by zerver »

Awesome idea! Some kind of visually smooth transition between LOS/Radar/Neither would also be nice. I.e. the unit or radar dot fades in/out. The infotex changes could also be visually smoothened for extra eyecandy.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: LOS

Post by Forboding Angel »

I can haz luaz for #2 plox? Daddy liek.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: LOS

Post by Beherith »

Cant share the lua yet, because it requires a couple lines of change in the engine sauce. If you are still interested, I can share my spring binary.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: LOS

Post by Google_Frog »

Do #2. I have already overwritten a ridiculous amount of engine behaviour so it may as well be done from the start.

#1 would be good if it works similar to how I want it to and won't randomly stop working in the future. But if you already have #1 there is no harm in including it if it can be disabled easily.
Pako
Posts: 174
Joined: 12 Jul 2009, 18:57

Re: LOS

Post by Pako »

If it has not been fixed yet the infotex generation is horribly bad. It is very slow and unflexible. It could be optimized to near real time but better yet move the generation to GPU. Should be failry easy. Just do every sensor in it's own texture and if the old type texture is still needed generate it with GPU.

Just for the LOS shader would it be faster or easier when you have multiple and smaller "alpha textures"?
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: LOS

Post by Beherith »

Pako, feel free to dig into engine code. It would be a boon to get cheaper and faster LOS texture updates.
Pako
Posts: 174
Joined: 12 Jul 2009, 18:57

Re: LOS

Post by Pako »

You didn't answer the question. Is it easier to work with multiple 1 bit texture than with the infotexture? It is probably just few lines of code to generate those 1-bit textures.
(note the texture are "all" different sizes)
Different textures:
airLOS
LOS
Radar
Jammer
Sonar
User avatar
Licho
Zero-K Developer
Posts: 3803
Joined: 19 May 2006, 19:13

Re: LOS

Post by Licho »

If you go engine way, several mods have visual los > radar los so it makes no sense to add noise for areas under visual los even if they miss radar. (Switch)
Pako
Posts: 174
Joined: 12 Jul 2009, 18:57

Re: LOS

Post by Pako »

Licho wrote:If you go engine way, several mods have visual los > radar los so it makes no sense to add noise for areas under visual los even if they miss radar. (Switch)
It seems to go gadget/widget way -> very easy to change.

I did the alpha texture uploading, it is blazing fast and easier than I imagined and works perffectly.
old way: 280 FPS -> 47 FPS
new way: 280 FPS -> 200 FPS (270FPS with optimized)

Even the texture generating works fine in Lua, only thing I didn't got yet working is blending and interpolating the alpha textures to the Lua infotex.(not necassary if the shader is changed to use the alpha textures)

I have no idea how to set the GL blending operators.

Code: Select all

gl.RenderToTexture(myInfoTex,
	function()
    gl.Clear(GL.COLOR_BUFFER_BIT,0,0,0,1)

    --gl.LogicOp(GL.OR) --MAKE blending and inerpolating???
    --gl.TexEnv(GL.TEXTURE_ENV, GL.TEXTURE_ENV_MODE, GL.BLEND)
--gl.BlendFunc(GL.ONE, GL.ONE)
  
      gl.Color(0,1,0,1)--gadget will decode the colors
      gl.Texture("$sensortex_radar")
      gl.TexRect(-1,-1, 1, 1,0, 0, 1, 1)
  
      gl.Color(1,0,0,1)
      gl.Texture("$sensortex_los")
      gl.TexRect(-1,-1, 1, 1,0, 0, 1, 1)
  
        gl.Color(0,0,1,1)
        gl.Texture("$sensortex_jammer")
        gl.TexRect(-1,1, 1, -1)
  gl.Texture(false)
end)
User avatar
MidKnight
Posts: 2652
Joined: 10 Sep 2008, 03:11

Re: LOS

Post by MidKnight »

Why not do way #1, then allow it to switch to a gadget if the modders have specified one?
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: LOS

Post by smoth »

I don't like 1:

ONLY EFFECTS TERRAIN

uneeded bloat for the engine.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: LOS

Post by Beherith »

Pako, having 1 texture is very important, as texture lookups are expensive on the gpu side; doing 5 lookups is significantly expensive.
Edit: sonar can be merged into radar, as well as jammer (radar-jammer)
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: LOS

Post by Jools »

smoth wrote: ONLY EFFECTS TERRAIN
What does this mean? How are units visible outside of LOS?
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: LOS

Post by Anarchid »

How are units visible outside of LOS?
1) If they are set to always visible.
2) There is other stuff besides units that is not terrain, ex: features. these are also usually always-visible.
Post Reply

Return to “Engine”