I am sort of new to Blender. I am rendering some scenes using Blender Python, where I have some random sun lights used to light up the scene. However, sometimes the rendered images appear very dark. While investigating I think the issue is because the scene is being rendered using the scene world lighting. When, I uncheck the scene world lighting, the scene looks brighter. But when I render the scene, it still applies the scene world lighting. How can I disable the scene world lighting in Blender and in python? I want my scene to only be affected by the scene lights I set up.
Not sure what you mean by “blender Python”, I presume you are simply rendering using Blender.
When you disable Scene World in the viewport options Blender uses its included HdrI’s as the world lighting in the viewport. This does not effect the final render. The final render always uses the scene world. (unless you use the “viewport render” option which only works for Eevee).
To get the same lighting in final render as the viewport with the bundled HDRI’s you have to add the hdri to your world settings in the shader editor.
The hdri’s are in your Blender program folder in the studio lights subfolder.
(the right hand window is the shader editor set to “world” instead of “object”)
Now your “scene world” will resemble the viewport world.
Edit
To clarify instead of " Render without scene world lighting" you need to make the scene world lighting resemble the viewport, if that makes sense.
Edit2
I forgot to mention, if you only want lighting and reflections from the HDRI but do not want it to be visible use this setup in the world shader.
Just to clarify if I understand everything correctly. The scene I see in the viewport is where Blender uses a default HDRI. With the render, Blender used the scene world which is just a dark gray background. So the render appears dark as the scene is only lit using the lights that I have set up. With the World shader you defined, I am essentially putting my scene in some environment with its own lighting, so that the render/scene appears brighter.
Is my understanding correct?
As mentioned above, my overall goal was so that my render appears brighter as it was dark. I am using the studio hdri and it seems to be working.
However, I want to make it so that the shadows that appear on the object are only due to the lights I have set up. Does the lighting from the HDRI/shader cause shadows? If so, is there a way to lower the strength of the lights from the world shader? Another idea I has is to increase the strength of my lights.
The Hdri in the world shader will give you shadows and reflections.
If you only want the render to be lighter, without extra shadows and reflections, you can delete the environment node and use the top background color value to add “ambient light” at a strength of 1 it will not give you noticeable shadows. This will “lighten” the shadows of your normal lights as well, it will also effect reflections.
in this example I gave background A a lighter colour background B is the visible colour but does not light the scene.
The other way to “lighten” the render would be to adjust the exposure and gamma settings in the render properties tab.
Just to clarify what you are seeing in your viewport screenshot is the result of the forest hdri (not the studio one.)
To make things a little more tricky in the view-port shader options you can blur the hdri (in your screenshot it is blurred).
Unfortunately it is not possible to blur the hdri in the world shader settings, if you want to use a blurred hdri in the world settings to light your scene you would have to blur the hdri file in photoshop/gimp etc and use the new blurred file in the environment node.
One issue is that my the lights that I set up doesn’t show up in the render. As seen in the image, I increased the strength of my light and it can be seen in the viewport but not in the render.
Because you can not use a diffuse shader as a node for a light you need to use an emission shader.
By using a diffuse shader you are destroying the light.
The reason you had more light in the viewport view is because viewport view uses Eevee not Cycles, Eevvee can nor use nodes for lights. In render preview it uses cycles and the nodes.
You have 2 options
1 Change all the diffuse shaders in all your light’s node setups for emission shaders.
2 do not use nodes for the lights. Uncheck the “use nodes” button in the shader editor for each light.
Here is a copy of your file I have changed all your node setups for the lights to use an emission shader.
If you do not plan to do anything fancy with the lights there is no point in using the nodes. you will find that if you uncheck the “use nodes” button in the file I have corrected there will be no difference in the lighting (an emission shader with a value of 1 is the same as not using nodes for the lights at all.)
Note that you are using cycles render engine not Eevee, so to see the same lighting in the viewport as the final render you need to be in “render preview” not “material preview”.