Changing Built-in Properties

Compiling, libraries, modules, coding guidelines and porting

Moderators: jesterKing, stiv

Post Reply
sgraham
Posts: 0
Joined: Fri Oct 04, 2013 5:47 am
Location: California, Bay Area

Changing Built-in Properties

Post by sgraham » Fri Oct 04, 2013 6:48 am

First, my question:
I am having trouble finding where the code lives which tells Blender what properties to build into the UI by default. I was assuming this would live in a Python file somewhere, but simply doing a search of all the files I was unable to come up with anything that looked like what I'm trying to find. Specifically, I see that by default in the world settings, there are 2 choices for rendering Indirect Lighting "Raytrace" and "Approximate", and switching between them enables/disables Indirect Lighting. I want to change this so it does not become disabled. Where can I find the code where this is being set up?

Hovering over the button I can see the Python binding, but when I search the code for parts of that string, I come up with only C files and I don't see any enabling/disabling going on.. but maybe I don't understand how this is working. Any pointers appreciated.




Second, some boring backstory about what I'm trying to do for those who are interested:
Hello there! This is my first post and code work for Blender. I've been working on Effects in the Animation industry for 7 years. I've used a lot of software in this time but I am relatively new to Blender. I have been using it for a few weeks and I think it is an excellent piece of software with just a couple features missing from what I need for my current personal project. The main feature I want is the ability to bake Indirect Lighting for games. But the latest Blender 2.68a has some issues with Indirect Lighting. (I take it not many people use Blender Render anymore?)

For Blender Render, there is no raytraced Indirect Lighting, which is surprising, but also the Approximate Indirect Lighting is rather broken and looks totally wrong. It appears to me that some of the cached data has normals going the wrong direction or something. Both of these factors make baking Indirect using Blender Render useless. Approximate is also broken in that you can have Occlusion+env lighting OR Indirect Lighting, not both. I have verified this behavior looking at the code. Fixing this should be rather simple and is on my todo list. I will also check out the code for Approximate and see if there is anything I can do there.

The Cycles Renderer is beautiful, but as many of you know it lacks a bake feature which makes it useless for games or even baking expensive scenes for film. Adding a bake feature would be hugely valuable IMHO.

From what I understand the way Cycles works internally it might make baking a rather difficult feature to add, though I'm sure it could be hacked to do it, I figured it would be simpler to implement my own Indirect Lighting inside the Blender Render.

I now have a working raytracing version of Indirect Lighting written in a way that can hopefully be patched back to the main branch of the repository relatively painlessly. My only issue at this point is figuring out how/where the built-in properties can be changed so when I choose "Raytrace" mode, it doesn't disable the properties for Indirect Lighting.

I will attach a test render to show my Raytraced results compared to Approximate. I will say that the brokenness of Approximate looks very much like an early test render I did where I was getting normals facing the wrong direction. I had to bake out a pointcloud to debug my situation.

Images to follow...

sgraham
Posts: 0
Joined: Fri Oct 04, 2013 5:47 am
Location: California, Bay Area

Post by sgraham » Fri Oct 04, 2013 7:12 am

Image
My implementation of Raytracing Indirect Lighting.



Image
Approximate method



Image
Example issues with Approximate method
A - Shows problem of floor sampling the cube incorrectly, whatever is happening here, it is not getting a shadow on the box.
B - This area should definitely getting some bounce light from the floor, might also have problem of reversed normals, therefore sampling inside the box.

sgraham
Posts: 0
Joined: Fri Oct 04, 2013 5:47 am
Location: California, Bay Area

Post by sgraham » Fri Oct 04, 2013 6:50 pm

I looked quite a bit more last night, this one is killing me. The closest thing I can find is the file source/blender/makesrna/intern/rna_world_gen.c

line 2561 it looks like this is where the property for the "gather method" button is being set up.

Code: Select all

EnumPropertyRNA rna_WorldLighting_gather_method = {
	{(PropertyRNA *)&rna_WorldLighting_passes, (PropertyRNA *)&rna_WorldLighting_indirect_bounces,
	-1, "gather_method", 3, "Gather Method",
	"",
	0, "*",
	PROP_ENUM, PROP_NONE | PROP_UNIT_NONE, NULL, 0, {0, 0, 0}, 0,
	rna_World_update, 0, NULL, NULL,
	0, -1, NULL},
	WorldLighting_gather_method_get, WorldLighting_gather_method_set, NULL, NULL, NULL, NULL, rna_WorldLighting_gather_method_items, 2, 0
};
It has a get/set function assigned to it "WorldLighting_gather_method_set", but looking at that function it doesn't appear to disable/enable anything...

Code: Select all

void WorldLighting_gather_method_set(PointerRNA *ptr, int value)
{
	World *data = (World *)(ptr->data);
	data->ao_gather_method = value;
}
but I'm not sure I would expect that anyway, because there is more than one place which disables/enables the indirect settings.. for example unchecking the indirect lighting checkbox also disables the indirect settings.

I don't see anything too significant looking at the actual properties which get disabled/enabled either... which might make more sense as a place to have that information, because they could potentially disable/enable themselves based on certain criteria/context. Alas.. it's not there. At least not from what I can tell. These are rather difficult to read though.

I have also searched for the words "Only works with Approximate gather method" and came up with nothing... where is this coming from??

sgraham
Posts: 0
Joined: Fri Oct 04, 2013 5:47 am
Location: California, Bay Area

Post by sgraham » Fri Oct 04, 2013 7:15 pm

Bah! Just found it. Turns out Windows explorer's search within files failed me again. I resorted to my old favorite linux tcsh search alias and it found it no problem. I even have .py files listed as files to search within in my indexing settings. Lame.

The file is here if curious:
release/scripts/startup/bl_ui/properties_world.py

fxrex
Posts: 0
Joined: Fri Sep 13, 2013 8:03 am
Location: Nigeria

Post by fxrex » Mon Oct 07, 2013 10:20 am

This is really lovely stuff. The raytraced version looks just like full GI. It's really exciting, considering the fact that one has full control over the exact amount of colour bleeding from each object. Please keep up the great work.

Post Reply