• Announcements

    • Detrux

      Site Relaunched   10/13/2016

      Welcome back to BFEditor.org! We've upgraded the forum software, removed the spammers, and improved security. Apologies for the downtime! Det
Sign in to follow this  
Followers 0
Kiaksar2142

BF2142 Night map lighting with lightsources

28 posts in this topic

Hey guys! And I'm really happy to see this forum alive again =)

Can anyone help me here about one problem in bf2editor (for 2142)
I made a map for 2142 with night setting. 
Its all great works like charm so far no problems at all!

However the problem is that ingame i put some street lamps. (the ones from leipzig with lightsource) but i can't make them to create lighting for terrain.
for example if you remember Liberation of leipzig or in Yellow Knife map the lamps in that map were creating lighting of terrain. But i cant make them to do so.
is there any way to make lightsources to create proper terrain lighting? I tried all of the lightsources available on game but they also didnt do anything =/ 
After tons of work, I lightmapped the map, it created very small dot of lighting but nothing more. 
I temporarily fixed that problem by brightening the color of textures with color tool with new layer so it looks like the lightning.
I know that to make proper lighting of objects i need lightmap samples or to create lightmaps in 3dxMax or use bfmeshviewer. But what about terrain? how can i make lamps to create lighting of terrain like it was in Leipzig or Yellow Knife maps?

Thank you in advance =) 

Share this post


Link to post
Share on other sites

I don't know if it will work in 2142 or not, but this is how I code dynamic light sources in BF2.  It should be fairly similar. This type of light should light the terrain as well as most other type of objects. You'll need to change the attached glow to an object that exists in BF2142.. maybe "glow" does exist.. I don't know. For BF2 I put this in objects/common/lightsources/

MyLightBundle.con

ObjectTemplate.create Bundle MyLightBundle
ObjectTemplate.createdInEditor 1

include MyLightBundle.tweak

MyLightBundle.tweak

rem *** Generated with Bf2Editor.exe [created: 2016/9/25 23:57]
ObjectTemplate.activeSafe Bundle MyLightBundle
ObjectTemplate.modifiedByUser "Michael"
ObjectTemplate.saveInSeparateFile 1
ObjectTemplate.createdInEditor 1
ObjectTemplate.floaterMod 0
ObjectTemplate.hasMobilePhysics 0
rem -------------------------------------
ObjectTemplate.addTemplate MyLightBundle_LightSource

rem --  CHANGE THIS TO A GLOW THAT EXISTS IN BF2142
ObjectTemplate.addTemplate glow
rem -------------------------------------

ObjectTemplate.create LightSource MyLightBundle_LightSource
ObjectTemplate.modifiedByUser "Michael"
ObjectTemplate.createNotInGrid 1
ObjectTemplate.createdInEditor 1
ObjectTemplate.lightType Spot
ObjectTemplate.isDynamic 1
ObjectTemplate.castsStaticShadow 1
ObjectTemplate.castsDynamicShadow 0
ObjectTemplate.selfLights 1
ObjectTemplate.selfShadows 1
ObjectTemplate.supportsPerVertex 1
ObjectTemplate.supportsPerPixel 1
ObjectTemplate.supportsGlow 1
ObjectTemplate.supportsEmitter 1
ObjectTemplate.affectLightmappedObjects 1
ObjectTemplate.affectingType 0
ObjectTemplate.attenuationRange1 1
ObjectTemplate.attenuationRange2 15
ObjectTemplate.color 1/1/1
ObjectTemplate.speccolor 1/1/1
ObjectTemplate.HDRIntensity 1
ObjectTemplate.coneAngle1 20
ObjectTemplate.coneAngle2 22.5
ObjectTemplate.projectorTexture 
ObjectTemplate.projectorFov 1.0472
ObjectTemplate.projectorAspect 1
ObjectTemplate.projectorNear 0.001
ObjectTemplate.projectorFar 5
ObjectTemplate.enabled 1
ObjectTemplate.fov 8
ObjectTemplate.objectShadows 1
ObjectTemplate.shadowIntensity 1
ObjectTemplate.softness 4
ObjectTemplate.intensity 0.1
ObjectTemplate.flicker 0
ObjectTemplate.scale 1/1/1

 

Edited by Coronaextra

Share this post


Link to post
Share on other sites

Coronaextra,
Thank you for an advice, mate! I will try this tomorrow and will reply back if it worked or not!

Share this post


Link to post
Share on other sites
23 hours ago, Coronaextra said:

 

I tried this method it created lighting but it kinda screwed my whole terrain: 
here is screen:
x5nPmpI8r70.jpg
Do you know how can i fix it?

Thanks in advance =)
 

 

Edited by Kiaksar2142

Share this post


Link to post
Share on other sites

@ Kiaksar2142

You need to find a lamp post which lights up the ground in a default map

Then find the called for files associated with its lighting effect

Looking through Liberation_Of_Leipzigs StaticObjects.con file are many entries like below

rem *** bp1_housespot ***
Object.create bp1_housespot
Object.absolutePosition -113.611/20.346/69.329
Object.rotation 100.0/0.0/0.0

rem *** glow4 ***
Object.create glow4
Object.absolutePosition -113.662/25.663/69.390

rem *** glow4 ***
Object.create glow4
Object.absolutePosition -133.352/26.395/68.377

rem *** BigSpot ***
Object.create BigSpot
Object.absolutePosition 150.203/40.313/2.999

rem *** Lamp_post_point ***
Object.create Lamp_post_point
Object.absolutePosition 131.737/30.138/-26.161

rem *** houselight_big ***
Object.create houselight_big
Object.absolutePosition 80.107/21.996/96.118

rem *** houselight_big ***
Object.create houselight_big
Object.absolutePosition 83.342/20.773/97.931

rem *** Lamp_post_point ***
Object.create Lamp_post_point
Object.absolutePosition -53.905/20.397/118.913

 

Also by deleting the contents of the StaticObjects.con file,you will know if the lit ground has anything to do with the lightmaps

 

 

 

Share this post


Link to post
Share on other sites

yeah but as far as I remember lighting up the terrain happens only after lightmapping.
Cos i tried to remove them. but lights remained. =/
 

Share this post


Link to post
Share on other sites

So the ground (terrain) lighting is connected to lightmapping.
any ideas how to fix this issue with screwed lighting as i showed in picture?

Thanks.

Share this post


Link to post
Share on other sites

Again, you will need to elaborate. The only errors I can see in that picture are the red errors in the output window but those have nothing to do with lightmaps. I can see from the picture that your terrain has lightmaps? So what is the problem?

Share this post


Link to post
Share on other sites

The problem is not a lightmapping. Problem is that the lightsource doesnt create normal accurate lighting on terrain after lightmapping.

BTW, here is what i get after i attached the custom glow you gave me to a street lamp.

I must admit that it created a lighting on terrain but its not accurate.
PEFr-wC1o2A.jpg


And Here is photos of editor lightsources enabled: 
YwD7Fc5jHW0.jpg

So as you can see problem is not connected to lightsources.. somehow its connected to lightmap settings =/
i tried tons of options of lightmapping (terrainlight settings) but they doesnt seem to make any difference...

I really wonder how the maps like Yellow knife and leipziq were made with these terrain lighting from lamps

Edited by Kiaksar2142

Share this post


Link to post
Share on other sites

Well, if the light I posted is causing problems then remove it and use one of the ones DEVILMAN posted above. Try each of the BF2142 lightsources until you find one that does what you want. Also note that the editor and game use different shaders and the results you see in each will not be exactly the same.

Share this post


Link to post
Share on other sites
5 hours ago, Coronaextra said:

Well, if the light I posted is causing problems then remove it and use one of the ones DEVILMAN posted above. Try each of the BF2142 lightsources until you find one that does what you want. Also note that the editor and game use different shaders and the results you see in each will not be exactly the same.

yeah i know that, bro. they differ (editor and game) 
and yeah i tried all of lightsources (each of them) but none of them worked.
i LOVED the dynamic lightsource you gave me thou)
I tweaked it so it looks even more realistic. would be awesome to be able to change it color (light color) too.
however the terrain lighting problem still remains =/ 
I also tried to use those the DEVILMAN posted. none of them worked =/ 
 

Edited by Kiaksar2142

Share this post


Link to post
Share on other sites

to change the color of the light  just change these lines

ObjectTemplate.color 1/1/1
ObjectTemplate.speccolor 1/1/1

Also, I still fail to see the problem you are talking about. is it the white area on the road? Does that change when you change the SinglePointColor?

Share this post


Link to post
Share on other sites
17 hours ago, Coronaextra said:

to change the color of the light  just change these lines


ObjectTemplate.color 1/1/1
ObjectTemplate.speccolor 1/1/1

Also, I still fail to see the problem you are talking about. is it the white area on the road? Does that change when you change the SinglePointColor?

yes the white choatic area on the road (terrain) is the lighting from lamp. and yes it does change when i change singlepointcolor. but the problem is that the lighting isnt normal) I mean that it should create neat round lighting from the lamp but as you can see light is spreaded here and there chaotically =/

btw, Thanks for help with colors)
 

Share this post


Link to post
Share on other sites

That is the pointlight channel (red channel) of the terrain lightmaps. The presense of the coded dynamic light is what is causing it, since the editor sees it as a point light source.

However, that only works in the editor. In the game, the red lightmap channel for terrain is used for water opacity and nothing else. It's actually a really stupid way of doing things but we play with the toys that DICE gave us.

So, since you will only see this in the editor, you could just ignore it, or you could set the SinglePointColor to black so you can't see it, or you could remove or disable the pointlights before lightmapping, or you could open the lightmaps in photoshop and paint that area of the red channel black.

Share this post


Link to post
Share on other sites
On 10/22/2016 at 9:47 PM, Coronaextra said:

That is the pointlight channel (red channel) of the terrain lightmaps. The presense of the coded dynamic light is what is causing it, since the editor sees it as a point light source.

However, that only works in the editor. In the game, the red lightmap channel for terrain is used for water opacity and nothing else. It's actually a really stupid way of doing things but we play with the toys that DICE gave us.

So, since you will only see this in the editor, you could just ignore it, or you could set the SinglePointColor to black so you can't see it, or you could remove or disable the pointlights before lightmapping, or you could open the lightmaps in photoshop and paint that area of the red channel black.

Thank you for giving an idea ) I am now just painting green channel of lightmap in Photoshop to create terrain lighting  and it works great! =)

But i have one problem with attaching dynamic glow light to Lamps!
When i put custom MyLightBundle you gave me in objects glow (or lightsources) folder it works in my lamps and they create dynamic lighting!
but as its a custom map, i want the lamp with dynamic light to be in my maps and work on other computers too.

I tried to add mylightbundle to lamp's tweak file but it didnt worked.
here what i did:

 

rem *** Generated with Bf2Editor.exe [created: 2006/9/19 2:30]
GeometryTemplate.setSubGeometryLodDistance 0 0 15
GeometryTemplate.doNotGenerateLightmaps 0
GeometryTemplate.lightmapOverride 0
GeometryTemplate.compressVertexData 1
GeometryTemplate.maxTextureRepeat 16
ObjectTemplate.activeSafe Bundle bp1_lamp_post_single_cb_sign
ObjectTemplate.creator DICE-SVUKANOVI1:svukanovic
ObjectTemplate.modifiedByUser "svukanovic"
ObjectTemplate.saveInSeparateFile 1
ObjectTemplate.geometry bp1_lamp_post_single_cb_sign
ObjectTemplate.setCollisionMesh bp1_lamp_post_single_cb_sign
ObjectTemplate.mapMaterial 0 metal_solid 21
ObjectTemplate.mapMaterial 1 concrete 78
ObjectTemplate.mapMaterial 2 glass_common 17
ObjectTemplate.mapMaterial 3 metal_thin 20
ObjectTemplate.hasMobilePhysics 0
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.physicsType Mesh
rem -------------------------------------
ObjectTemplate.addTemplate bp1_lamp_post_single_lightcone
ObjectTemplate.addTemplate Levels/MyMap/Objects/bp1_lamp_post_single_c/MyLightBundle.con
ObjectTemplate.setPosition -0.837428/5.22201/0
ObjectTemplate.addTemplate Lamp_post_point
ObjectTemplate.setPosition -2.28149/2.02053/0
rem -------------------------------------

When i remove mylightbundle from object folder in my BF2142, it doesnt works. WHich means that object can't take the MyLightBundle file from map folder.
Does anyone knows how to bypass this problem and make lamps work as custom object in my map's folder?
 

Share this post


Link to post
Share on other sites

There are several threads in these forums that explain how to pack/load custom content in a map, here is one of them. The tutorial focuses  on loading custom textures, but the concept is the same for any content.

However, if the lightbundle is the only object you want to include with your map, creating archives and filemounts for it is unnecessary. You can place the content of the bundles con and tweak into your maps tmp.con file. The game will load any code from this file at runtime.

ObjectTemplate.addTemplate Levels/MyMap/Objects/bp1_lamp_post_single_c/MyLightBundle.con

the addtemplate command does not use a path. Only use the template name. If the template exists and it location is indexed with the filemount system, the game will find and load it.

Share this post


Link to post
Share on other sites

THank you a lot mate =)
it really worked!
Now dynamic light is sticked with lamp and i can see dynamic lighting in editor!
However i have another problem (
it doesnt work ingame
I included custom objects and including tmp.con file to be loaded in init.con, But it still doesnt show up
any ideas how to fix it?
here is the photo!
its visible in editor as you can see.
but when i pack the map and go ingame, the dynamic lighting is not visible!
(dont mind the black thing on that lamp. i just forgot to remove it)
Untitled.jpg
and yeah i added custom objects (custom lamp with its dynamic lightsource), lightsource itself and tmp.con

here is my init.con:
run tmp.con

rem Static Objects
run objects/StaticObjects/kiaksar2142/bp1_lamp_post_single_c_kiak/bp1_lamp_post_single_cb_kiak.con
run objects/StaticObjects/kiaksar2142/DynamicLampLight/DynamicLampLight.con

However it doesnt work ingame.
Any ideas bro?

Thank you in advance =)

Share this post


Link to post
Share on other sites

Try this..

In the lights tweak change it from a spot light to a point light.

change this

ObjectTemplate.lightType Spot

to this

ObjectTemplate.lightType Point

 

Also you could try this. I've discovered recently that you can get different results with different video cards and different video settings, so the light's I've made now use two different light types to "cover all bases". It seems to work well.

junglelight_01_zpsupxdhjx8.png

 

ObjectTemplate.create Bundle Junglelight
ObjectTemplate.createdInEditor 1

include Junglelight.tweak
rem *** Generated with Bf2Editor.exe [created: 2016/9/25 23:57]
ObjectTemplate.activeSafe Bundle Junglelight
ObjectTemplate.modifiedByUser "Michael"
ObjectTemplate.saveInSeparateFile 1
ObjectTemplate.createdInEditor 1
ObjectTemplate.floaterMod 0
ObjectTemplate.hasMobilePhysics 0
rem -------------------------------------
ObjectTemplate.addTemplate Junglelight_LightSource_Spot
ObjectTemplate.addTemplate Junglelight_LightSource_Point
ObjectTemplate.addTemplate glow
rem -------------------------------------

rem THIS LIGHTS EVERYTHING EXCEPT TERRAIN
ObjectTemplate.create LightSource Junglelight_LightSource_Spot
ObjectTemplate.modifiedByUser "Michael"
ObjectTemplate.createNotInGrid 1
ObjectTemplate.createdInEditor 1
ObjectTemplate.lightType Spot
ObjectTemplate.isDynamic 1
ObjectTemplate.castsStaticShadow 1
ObjectTemplate.castsDynamicShadow 1
ObjectTemplate.selfLights 1
ObjectTemplate.selfShadows 1
ObjectTemplate.supportsPerVertex 1
ObjectTemplate.supportsPerPixel 1
ObjectTemplate.supportsGlow 1
ObjectTemplate.supportsEmitter 1
ObjectTemplate.affectLightmappedObjects 1
ObjectTemplate.affectingType 0
ObjectTemplate.attenuationRange1 1
ObjectTemplate.attenuationRange2 10
ObjectTemplate.color 1.28667/0.773333/0
ObjectTemplate.speccolor 1.28667/0.773333/0
ObjectTemplate.HDRIntensity 1
ObjectTemplate.coneAngle1 20
ObjectTemplate.coneAngle2 22.5
ObjectTemplate.projectorTexture 
ObjectTemplate.projectorFov 1.0472
ObjectTemplate.projectorAspect 1
ObjectTemplate.projectorNear 0.001
ObjectTemplate.projectorFar 5
ObjectTemplate.enabled 1
ObjectTemplate.fov 8
ObjectTemplate.objectShadows 1
ObjectTemplate.shadowIntensity 1
ObjectTemplate.softness 4
ObjectTemplate.intensity 1.0
ObjectTemplate.flicker 0
ObjectTemplate.scale 1/1/1

rem THIS LIGHTS TERAIN AND NOTHING ELSE
ObjectTemplate.create LightSource Junglelight_LightSource_Point
ObjectTemplate.modifiedByUser tho
ObjectTemplate.createNotInGrid 1
ObjectTemplate.createdInEditor 1
ObjectTemplate.lightType Point
ObjectTemplate.isDynamic 1
ObjectTemplate.castsStaticShadow 0
ObjectTemplate.castsDynamicShadow 0
ObjectTemplate.selfLights 0
ObjectTemplate.selfShadows 0
ObjectTemplate.supportsPerVertex 0
ObjectTemplate.supportsPerPixel 0
ObjectTemplate.supportsGlow 0
ObjectTemplate.supportsEmitter 0
ObjectTemplate.affectLightmappedObjects 0
ObjectTemplate.affectingType 0
ObjectTemplate.attenuationRange1 0
ObjectTemplate.attenuationRange2 10
ObjectTemplate.color 1.0/0.773333/0
ObjectTemplate.speccolor 1.28667/0.773333/0
ObjectTemplate.HDRIntensity 1
ObjectTemplate.coneAngle1 20
ObjectTemplate.coneAngle2 22.5
ObjectTemplate.projectorTexture 
ObjectTemplate.projectorFov 1.0472
ObjectTemplate.projectorAspect 1
ObjectTemplate.projectorNear 0.001
ObjectTemplate.projectorFar 5
ObjectTemplate.enabled 1
ObjectTemplate.fov 8
ObjectTemplate.objectShadows 0
ObjectTemplate.shadowIntensity 0
ObjectTemplate.softness 0
ObjectTemplate.intensity 1.0
ObjectTemplate.flicker 0
ObjectTemplate.scale 1/1/1

 

Share this post


Link to post
Share on other sites

Thank you bro, i will test that out and will report back =) 

Share this post


Link to post
Share on other sites
On 11/22/2016 at 9:42 AM, DEVILMAN said:

Just for curiousitys sake,why dont you try adding your glow effects directly into your mod,and see if they show ingame

Bro, thats what i did, but it doesnt works =/
I attached dynamic light effect to my lamps! they show up in editor, but they dont show ingame.
and yeah i added them in  tmp.con  but still they didnt showd up =(
any advices?

Share this post


Link to post
Share on other sites

My first guess is that you still haven't packed everything up correctly.

If you want, you can PM me a download link to your project and i'll take a look at it for you.

Share this post


Link to post
Share on other sites

Thank you guys for all help you wrote here =)
I finally made it to work as planned =))))

 

Share this post


Link to post
Share on other sites

I have one more question guys =)
How can i attach lightsource to an object that doesnt have lightsource originally?
I am trying to attach dynamic lightsource to billboard at the moment. but i cant make it to work ingame or in editor!
Here is my code: 

rem *** Generated with Bf2Editor.exe [created: 2017/01/19 4:13]
GeometryTemplate.setSubGeometryLodDistance 0 0 50
GeometryTemplate.doNotGenerateLightmaps 0
GeometryTemplate.lightmapOverride 0
GeometryTemplate.compressVertexData 1
GeometryTemplate.maxTextureRepeat 16
ObjectTemplate.activeSafe SimpleObject ground_16x8_frame_kiak
ObjectTemplate.creator SVU-2:svu
ObjectTemplate.modifiedByUser "Kiaksar2142"
ObjectTemplate.saveInSeparateFile 1
ObjectTemplate.geometry ground_16x8_frame_kiak
ObjectTemplate.setCollisionMesh ground_16x8_frame_kiak
ObjectTemplate.mapMaterial 0 metal_solid 21
ObjectTemplate.mapMaterial 1 glass_common 17
ObjectTemplate.mapMaterial 2 concrete 78
ObjectTemplate.hasMobilePhysics 0
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.physicsType Mesh
rem -------------------------------------
ObjectTemplate.addTemplate PosterDynamicLighting
ObjectTemplate.setPosition -0.67323/6.80000/-0.00192222
rem -------------------------------------


As you see in last lines i added the lightsource. but i cant get it work ingame or in editor at all.
And yes, i added that lightsource in tmp.con and Init.con files.
can you please tell me what am i doing wrong? cos ingame i cant see the lightsource at all.
it is visible when i add it seperately, but i can't attach it to this billboard static object.

Thank you in advance!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0