• LightSpheres
    121 replies, posted
  • [img]http://www.cubeupload.com/files/53e800lightspheres.jpg[/img] What are these mysterious entities, you ask? Well, these things are LightSpheres: they forge a magical field of light around them, using lots of beautiful light sources which orbit the core of the LightSphere. These rotating orbs will form all kinds of different patterns when time progresses. Every LightSphere has a different pattern. You can change the color of the LightSpheres with the Color tool. I shall give you some pictures. [img]http://dl.dropbox.com/u/4081391/lightsphere.gif[/img] [img]http://www.cubeupload.com/files/afbe00gmconstruct0023.jpg[/img] Eager to try it out? Wait no longer and download it here: [url=http://www.garrysmod.org/downloads/?a=view&id=99588][img]http://www.garrysmod.org/img/?t=dll&id=99588[/img][/url] Installing is as easy as it gets. Drop the LightSphere folder in your addons folder... and you're done! Changelog: V1.1: Optimizations (thanks to various lua coders) Known issues: - The spheres eat FPS. Spawning more than 5 LightSpheres at a time will make your FPS drop to 20 and lower. Any coders who might help me with optimizing? - They look pretty boring without bloom on, so TURN THAT SHIT ON! (and lower Darken Amount to 0.14) Rate, comment, whatever :v: (also, if you use this for a pose or a machinima or something, please notify me! I'm curious :buddy:) Video by Hydrochlorider: [media]http://www.youtube.com/watch?v=o622K4P8ZFM[/media]
  • Avatar of CapsAdmin
  • I think the reason this lags is because of math.NormalizeAngle. Might also be sprites, you can try to use particles instead.
  • Avatar of Overv
  • [QUOTE=CapsAdmin;22200100]I think the reason this lags is because of math.NormalizeAngle. Might also be sprites, you can try to use particles instead.[/QUOTE] Yeah, it's definitely the rendering. I've done some benchmarking and the stuff in the loop takes such a small amount of time, os.clock() usually can't even measure it.
  • Avatar of CapsAdmin
  • [QUOTE=Overv;22200213]Yeah, it's definitely the rendering. I've done some benchmarking and the stuff in the loop takes such a small amount of time, os.clock() usually can't even measure it.[/QUOTE] But math.NormalizeAngle is pretty heavy. I tried using particles with this, and a for i=500 loop the math.normalize angle kills my gmod and it won't stop lagging either when it's done. I have to rejoin.
  • I'm going to bed now, thanks for the positive reactions! I thought nobody would find a use for it but I was wrong :buddy: I'll look at the optimizing stuff tomorrow.
  • Avatar of Overv
  • Look at that... FPS. [img]http://dl.dropbox.com/u/2399384/particles.jpg[/img] As CapsAdmin pointed out, the math.NormalizeAngle function is the bottleneck, because it's horribly written. Replace line 36 in cl_init.lua with this and you will experience an FPS increase of roughly 50%: [lua]local Forward = Angle( Ang * Seed1, Ang * Seed2, 0 ):Forward()[/lua]
  • Avatar of adamfiru
  • I did this [img]http://img227.imageshack.us/img227/6048/gmconstructflatgrassv50.jpg[/img] not too great but meh
  • Avatar of yakahughes
  • FREAKING WIN. This is absolutely awesome. [editline]02:17AM[/editline] The logo thing is sweet too. Very very nice work Dlaor, I don't even mind that you put your name on the logo.
  • Avatar of Bletotum
  • Most of the time the spheres are unintelligible patterns of chaos, but it's worth the wait when they gain more structure.
  • Avatar of Tobba
  • Gonna try to optimize this a little, should be pretty easy [editline]11:26AM[/editline] tried to optimize it, cl_init: [lua]include( "shared.lua" ) ENT.RenderGroup = RENDERGROUP_TRANSLUCENT local NormalizeAngle = math.NormalizeAngle local curTime = CurTime local dynamicLight = DynamicLight local SetMaterial = render.SetMaterial local DrawSprite = render.DrawSprite local GlowMat = Material( "sprites/light_glow02_add" ) function ENT:Draw() self:DrawShadow( false ) local R, G, B, A = self:GetColor() R = R / 255 G = G / 255 B = B / 255 A = A / 255 SetMaterial( GlowMat ) local Seed1 = self:GetDTFloat( 0 ) local Seed2 = self:GetDTFloat( 1 ) for i = 1, 180 do local Ang = ( self:EntIndex() + 1337 + curTime() ) * i //Yeah, random math makes awesome shit! local Size = ( 155 - i ) / 6 local Forward = Angle( NormalizeAngle( Ang * Seed1 ), NormalizeAngle( Ang * Seed2 ), 0 ):Forward() local Pos = self:GetPos() + Forward * i * 0.09 local Gray = i / 150 * 255 Gray = Color( Gray * R, Gray * G, Gray * B, Gray * A ) DrawSprite( Pos, Size, Size, Gray ) end end function ENT:Think() local R, G, B, A = self:GetColor() R = R / 255 G = G / 255 B = B / 255 A = A / 255 local DLight = dynamicLight( self:EntIndex() ) if ( DLight ) then DLight.Pos = self:GetPos() DLight.r = R * 255 DLight.g = G * 255 DLight.b = B * 255 DLight.Brightness = A DLight.Size = 128 DLight.Decay = 512 DLight.DieTime = curTime() + 1 end end[/lua]
  • Avatar of thelinx
  • [QUOTE=Tobba;22210822] [lua] function ENT:Draw() self:DrawShadow( false )[/lua][/QUOTE] Just curious, does this need to be set every time the entity draws?
  • Avatar of CapsAdmin
  • It's not enough. math.NormalizeAngle is just bad and it doesn't matter if you localize it. Look at the source of it, it's pretty bad.