Creating (emergency)Lights, how?

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:

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:

But from the side, you can clearly see it:

Do i need to change the rendermode or sth?

Assuming you’re using render.DrawSprite() then use PostDrawTranslucentRenderables.
Should get something like this

You gotta use proper hook.

And remember, dynamic lights wont work on flatgrass due to huge size of lightmap

Thanks! :slight_smile:

I actually used ents.Create(“env_sprite”), but i will check this out :slight_smile:

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 :confused:

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:

But if i just move a bit, not visible anymore:

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

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.

Well, maybe “won’t work” was a bit exaggerated, but:

http://i.imgur.com/BlvjFui.jpg[/t]

The lightmap scale DOES affect DynamicLights. Lower brightness/size values:

[t]http://i.imgur.com/tyntCn9.jpg

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.

Do not use the util.PixelVisible method, it is buggy as fuck. I learnt this the hard way when making this.

Instead, what you should do is create an “env_sprite” entity and use the following key-value pairs:



"model" - Texture of the sprite
"scale" - Size of the sprite
"rendermode" - The rendermode
"renderfx" - The renderFX


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]

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.

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.