Comments (9)
It worked like a charm!! Thank you so much. I really appreciate your efforts, thanks again :)
from blenderproc.
Of course! Keep up the great work.
from blenderproc.
Hey,
I am sure it is possible, but first let me understand what you are trying to do here.
What you want to do is that for each camera frame there is only one light? Do I understand that correctly?
from blenderproc.
Assuming this was your question, the current implementation does not offer that feature. However, it is super easy to implement.
I am going to highlight the necessary steps and if you need further assistance just ask.
The LightLoader
is similar to the CameraLoader
, which we draw inspiration of for this change you want:
This function is called for each line specified in your object file, right now. It creates a new light object for each line of the config.
BlenderProc/src/lighting/LightModule.py
Lines 39 to 54 in 46cd09d
What you could do is:
-
Move this creation step to the
__init__()
the creation happens in L44-L47. -
Save the created light
light_obj
in a member ->self.light_obj
. -
Use in the fct.
_add_light_source
theself.light_obj
instead of thelight_obj
-
Each call now sets the location value, to track this change you need to save this value in a keyframe (check the blender docu for more info on keyframes).
This is done as in theCameraLoader
:
BlenderProc/src/camera/CameraLoader.py
Lines 81 to 84 in 46cd09d
-
However, this increase the frame end counter of blender, which we don't want to do. I suggest adding a member to the
__init__
light counter ->self.light_counter
, which is counted up everytime_add_light_source
is called. -
This counter can then be used like it is done inside of the
_insert_key_frames
call:
self.light_obj.keyframe_insert(data_path='location, frame=self._light_counter) # the light counter needs to be inited with 0
self.light_obj.keyframe_insert(data_path='rotation_euler', frame=self._light_counter)
self._light_counter += 1
I hope this helps if you have any further questions, ask away.
Thanks for the idea, we will add a future like this in a future version of BlenderProc.
from blenderproc.
Thanks so much for the quick and really helpful response!! I will tackle this in the upcoming week. If it is ok with you, I will close the issue once I am done and hence sure that I do not have any more questions.
from blenderproc.
So basically the only script we are changing would be LightModule.py and if I only care about changing the location, it would look like this?
def __init__(self, config):
Module.__init__(self, config)
self._light_counter = 0
# Create light data, link it to the new object
self.light_data = bpy.data.lights.new(name="light", type="POINT")
self.light_obj = bpy.data.objects.new(name="light", object_data=self.light_data)
bpy.context.collection.objects.link(self.light_obj)
self.cross_source_settings = self.config.get_raw_dict("cross_source_settings", {})
self.light_source_collection = ItemCollection(self._add_light_source, self.cross_source_settings)
def _add_light_source(self, config):
self.light_obj.location = config.get_list("location", [0, 0, 0])
self.light_obj.keyframe_insert(data_path='location', frame=self._light_counter)
self._light_counter += 1
and my config would need to contain something like:
{
"module": "lighting.LightLoader",
"config": {
"lights": [
{
"type": "POINT",
"energy": 1000
},
],
"path": "<args:0>",
"file_format": "location"
}
}
Logically this should work but my RGB images are all very dark. I think there is a light source somewhere, as the model is lit slightly from one side but really subtly. I had a look at the corresponding Camera Scripts:
- do I need to set the initial light location somehow?
- do I need to transform the coordinates (the input to args:0 is exactly the same as for the camera coordinates apart for the missing rotation values)
from blenderproc.
Yes I think you are missing setting the energy value.
light_data.energy = config.get_float("energy", 10.)
I would add this to the top:
def __init__(self, config):
Module.__init__(self, config)
self._light_counter = 0
# Create light data, link it to the new object
self.light_data = bpy.data.lights.new(name="light", type="POINT")
self.light_data.energy = self.config.get_float("energy", 10.) # <- this line is new
self.light_obj = bpy.data.objects.new(name="light", object_data=self.light_data)
bpy.context.collection.objects.link(self.light_obj)
self.cross_source_settings = self.config.get_raw_dict("cross_source_settings", {})
self.light_source_collection = ItemCollection(self._add_light_source, self.cross_source_settings)
Then they should have the correct lighting.
I think the rest should be already correct, check it out and tell me if it worked.
from blenderproc.
Oh one addition, you have to move the energy
level on the samel level as the "path"
.
{
"module": "lighting.LightLoader",
"config": {
"energy": 1000,
"type": "POINT",
"path": "<args:0>",
"file_format": "location"
}
}
from blenderproc.
@pmcgrath249 please cite our work if you publish ;)
from blenderproc.
Related Issues (20)
- Incorrect object pose rendering when .obj files are used for bop_based dataset HOT 2
- Is there a way of rendering an asset as invisible to the camera but visible to the bproc.writer.write_coco_annotations? HOT 1
- Eager render data
- Not what I see in Blender HOT 1
- Regarding object 3D vertices in meters (8 corners and 1 centroid) extraction and project them to 2D image plane (pixel cordinate) HOT 1
- blenderproc quickstart on Mac M2 raises error. HOT 2
- Wrong Matrix Inversion HOT 4
- how to use rigidbody to fix the collision problem of ycb distractors with themselves as well as object of interest?
- ERROR: StructRNA of type Material has been removed HOT 9
- 13/5000 How can I use my images to replace textures HOT 5
- coco annotation merge for multiple .blend files HOT 2
- render hdr lighting without background HOT 2
- Unsuccessful quickstart HOT 5
- how to save object distance from camera in coco annotations HOT 7
- Duplicate linked does not work correctly with hierarchy.
- Rework MeshObject material manipulation HOT 2
- BrokenPipeError during BOP dataset generation
- Code/assets to generate the rendering of falling objects in your demo video HOT 2
- Render process break down without error. HOT 2
- ModuleNotFoundError: No module named 'blenderproc' HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blenderproc.