Points which are blurred due to depth of field appear to be "clamped" as in this example:
This seems to be due to the bounds of individual points not being correctly calculated in CReyes::insertGrid when there is focal blur (i.e. non-zero aperture). In particular, the bounds aren't expanded by the "circle of confusion" amount for each individual point, so the bounds still cover the original area (leading to the edges of the point being cut off).
The fix is relatively straight forward: add the circle of confusion to each point's bounds (similarly to how it's done for quads later in the same function).
Here's a patch (against revision 1129 of the SVN trunk) and the same scene rendered with the patch:
Also, could someone clarify what is stored in CRasterGrid::vertices (as this doesn't seem to be explicitly mentioned anywhere)?
As I understand it, the first 3 values always hold the X, Y and Z coordinates. The 10th value (i.e. "vertices") is used for the circle of confusion amount measured in samples (assuming depth of field is active in the scene).
After the first 10 values there are also CRenderer::numExtraSamples for additional colour channels. Is that right?
Are the other values (in the first 10) used for anything at the moment?
You're quite right. Thanks for the fix.
The vertices' format is probably going to be revised at some point, but currently it stores:
xyz (3 float)
color (3 floats)
opacity (3 floats, needed to composite correctly)
... extra samples for AOVs if any ...
All 10 are used, and are necessary. The 10th could be discarded in a non DOF context (I was planning to do this).
These correspond to the P,Ci,and Oi outputs from shading (plus and AOVs).
Incidentally, in the ideal case Oi and Ci should not be needed for unshaded grids. There's a chunk of code I have here which reallocates a fresh grid for shaded grids. This reduces memory overhead of unshaded grids - but it's a little tricky to make it work with multithreading, which is why it's not in there right now.
Maybe you've already considered this but I think it would be better to break the vertex data into separate arrays instead of the current ‘interleaved’ format.
This might make it easier for multithreading as you can then copy / swap pointers for the appropriate data (pointer swap can be done as an atomic operation).
There would also be benefits for caching and hardware prefetching. For example, in the current unshaded grid code, when you load the XYZ data the processor also has to load the rest of the cache line which contains data you don't want (colour, opacity, COC etc.).
If / when any of this code gets vectorised (SSE / Altivec) it may also be better to further break these into individual component arrays (i.e. separate arrays for X, Y, Z etc.). This avoids having to ‘swizzle’ the data once it's in the SIMD registers.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.