Hai,
I'm trying to do good looking emergency-lights.
What should i use for creating the light?
DynamicLight() looks ugly, because it doesn't really create a light at the position.
Any suggestions?
Sprites work well in conjunction with dynamic lights and can look something like this:
[url]http://www.twitch.tv/acecoolco/c/2464078[/url]
[url]http://www.youtube.com/watch?v=T7V8NZPBeDo[/url]
Alternatively you could buy VCMod which spawns an entity for each light...
Okay, i used sprites but now i've got this problem:
If you look straight at the sprite, you can't see it:
[IMG]http://i.imgur.com/TX1nwFV.jpg[/IMG]
But from the side, you can clearly see it:
[IMG]http://i.imgur.com/z0ks24D.jpg[/IMG]
Do i need to change the rendermode or sth?
Assuming you're using render.DrawSprite() then use PostDrawTranslucentRenderables.
Should get something like this
[IMG]http://i.imgur.com/kwtCDu5.png[/IMG]
You gotta use proper hook.
And remember, dynamic lights wont work on flatgrass due to huge size of lightmap
[QUOTE=Spencer;43575686]Assuming you're using render.DrawSprite() then use PostDrawTranslucentRenderables.
Should get something like this
[IMG]http://i.imgur.com/kwtCDu5.png[/IMG][/QUOTE]
Thanks! :)
I actually used ents.Create("env_sprite"), but i will check this out :)
EDIT:
NVM, got the sprite itself correctly.
And how did you achieve the light bowl? env_projectedtexture is a bit buggy atm
And using PostDrawTranslucentRenderables makes it visible through walls :/
[QUOTE=johnnyaka;43575984]Thanks! :)
I actually used ents.Create("env_sprite"), but i will check this out :)
EDIT:
NVM, got the sprite itself correctly.
And how did you achieve the light bowl? env_projectedtexture is a bit buggy atm
And using PostDrawTranslucentRenderables makes it visible through walls :/[/QUOTE]
You'll need to use util.PixelVisible to make sure it dosen't draw through walls and I have the FOV of the projected texture down very low so it dosen't cast so much behind itself.
should probably have mentioned, read the sandbox lamp code, that uses render.DrawSprite() so you should be able to get an idea from that
I tried some things with util.PixelVisible, but it's behaving strange...
If i directly look at the sprite, it's visible:
[IMG]http://i.imgur.com/eAitE4q.jpg[/IMG]
But if i just move a bit, not visible anymore:
[IMG]http://i.imgur.com/pjH3Uj0.jpg[/IMG]
The Code:
[LUA]
if util.PixelVisible(pos,6,PixVis) == 0 then return end
render.SetMaterial(matLight)
render.DrawSprite(pos,60,60,Color(255,0,0))
[/LUA]
I tried debuging util.PixelVisible, as soon as you don't look at the sprite, it's 0
Just look how gmod_lamp.lua does it.
Funny thing is, it never gets called at gmod_lamp.lua
[LUA]
local Visibile = util.PixelVisible( LightPos, 16, self.PixVis )
[/LUA]
"Visibile" is always nil, no matter where you look at it
[QUOTE=Robotboy655;43575716]And remember, dynamic lights wont work on flatgrass due to huge size of lightmap[/QUOTE]
Uh what's your source on that one? Lightmaps are simply precomputed textures that are slapped on top of the map brushes to give the illusion of lighting. Dynamic lights are completely unrelated to them.
[QUOTE=_Kilburn;43581099]Uh what's your source on that one? Lightmaps are simply precomputed textures that are slapped on top of the map brushes to give the illusion of lighting. Dynamic lights are completely unrelated to them.[/QUOTE]
Well, maybe "won't work" was a bit exaggerated, but:
[t]http://i.imgur.com/BlvjFui.jpg[/t]
The lightmap scale DOES affect DynamicLights. Lower brightness/size values:
[t]http://i.imgur.com/tyntCn9.jpg[/t]
[QUOTE=Robotboy655;43581269]Well, maybe "won't work" was a bit exaggerated, but:
[t]http://i.imgur.com/BlvjFui.jpg[/t][/QUOTE]
Oh I see. Doesn't look like a lightmap issue though, that looks more like the ground getting cut into smaller quads due to the way VVIS works. You can easily check that with mat_wireframe 1.
[QUOTE=johnnyaka;43581074]Funny thing is, it never gets called at gmod_lamp.lua
[LUA]
local Visibile = util.PixelVisible( LightPos, 16, self.PixVis )
[/LUA]
"Visibile" is always nil, no matter where you look at it[/QUOTE]
Do [B]not[/B] use the util.PixelVisible method, it is buggy as [I]fuck.[/I] I learnt this the hard way when making [url=http://coderhire.com/scripts/view/673]this[/url].
Instead, what you should do is create an "env_sprite" entity and use the following key-value pairs:
[code]
"model" - Texture of the sprite
"scale" - Size of the sprite
"rendermode" - The rendermode
"renderfx" - The renderFX
[/code]
Here's some example code:
[lua]
local sprite = ents.Create( "env_sprite" )
sprite:SetPos( Vector( 0, 0, 0 ) )
sprite:SetColor( Color( 255, 0, 0 ) )
sprite:SetKeyValue( "model", "sprites/light_glow01.vmt" )
sprite:SetKeyValue( "scale", 0.015 )
sprite:SetKeyValue( "rendermode", 5 )
sprite:SetKeyValue( "renderfx", 7 )
sprite:Spawn()
sprite:Activate()
[/lua]
[QUOTE=_Kilburn;43581665]Oh I see. Doesn't look like a lightmap issue though, that looks more like the ground getting cut into smaller quads due to the way VVIS works. You can easily check that with mat_wireframe 1.[/QUOTE]
Well yes, but not entirely.
BTW, mat_wireframe fucks up textures on all models.
Okay, got it working with the Entity.
Since i need a DynamicLight, is there any way to stop 2 lights mixing the colors?
When you spawn one red, and one blue, there is a big purple light...
Reconsider using entities. My entire system is client-side. Imagine 128 vehicles in the map, with x number of lights per vehicle. You'll start filling up the maximum of 8000 allowed really quick. PixVis really isn't that difficult to master.
Additionally; to prevent dynamic lights mixing, don't have them rendering at the same time.
[QUOTE=Acecool;43586202]Reconsider using entities. My entire system is client-side. Imagine 128 vehicles in the map, with x number of lights per vehicle. You'll start filling up the maximum of 8000 allowed really quick. PixVis really isn't that difficult to master.
Additionally; to prevent dynamic lights mixing, don't have them rendering at the same time.[/QUOTE]
It doesn't work properly in a lot of cases, especially when really close to a model.
That can be fixed.
I'm intrigued, tell me more.
Please do explain Acecool, I am also interested.
You have to calculate a true-yet-altered-position for pixelvisible in addition to using dot product on a view-dot for the size. Playing with the second arg in util.PixelVisible can yield better or worse results in terms of disappearing, but if you calculate a different position for the pixvis to handle you can eliminate disappearing by 100% until you are through it when it shouldn't render anyway.
I use angles in terms of displaying them as well, this eliminates the need for certain operations to be performed when deciding if it should render or not if it's facing away from you. Headlights face forward, side lights face sideways, brakelights, reverse lights are typically rearward to rear+side facing depending on the angle of the socket, turning signals can be dependent on the sockets.
It may take time to set up the vectors and angles if you don't have a tool to do it for you; I do, and I can also convert VCMod lights into my format on the fly or permanently.
If the OP decides to do this client-side without creating an entity per light, I'll be more than happy to help him make the code alterations. Jeezy and Evac, feel free to PM me, and I'll share a little bit more.
Well, this siren is for a gamemode which will require pretty many lights, so that would be good yea.
And how do you mean rendering them at different times?
As far as I know, you just create a DynamicLight and it renders itself doesn't it?
I sent you a Steam Friend-Invite (My name is "Johnny") :)
Don't forget about DynamicLight limit, which seems to be 31.
Yes and no. When you create a Dynamic Light, there are many values that can be added to it including Decay, DieTime, Size, Brightness, r,g,b, Dire, Key, MinLight, InnerAngle, OuterAngle, Distance, Brightness, Pos and there may be some that I'm missing.
Based on what you want to do, you'd want to change the size, and a few other things.
When you're inside a car, DynamicLight tends to show through; if you're in first person, and the driver of a vehicle, it's a good idea to set those particular dynamic lights slightly higher; this gives less headache/disco effect inside the car while spreading the radius in the world a little more. If you've ever ridden shotgun with law enforcement with lights running, you'll know that the splash on the world is greater than interior flash/splash.
If you flash lights, you'll want the decay to be high, and the dietime to be short. I set dietime to be 0.1 seconds from CurTime. I set decay anywhere from 1024 to 8196.
Dynamic lights are VERY RESOURCE INTENSIVE. You don't want to render dynamic lights on everything; only things that NEED to create a splash on the world, such as emergency lighting. Render 1 to 2 maximum at a time per vehicle; render distance for these should be fairly low. The higher the size, the more the frame hit, up to a maximum point. From that max point it doesn't matter how large you go. The issue with making them too large is that the brightness will wash-out the textures on the map; this isn't good. The trick is to balance the size / brightness in a way that it can be seen on the ground, brighter towards the source, but doesn't wash out the textures. It's a light, it should help you see more.
Accepted.
Sorry, you need to Log In to post a reply to this thread.