Cycles: change smoke color grid to not include density multiplied in.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Sun, 18 Feb 2018 02:16:29 +0000 (03:16 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Fri, 23 Feb 2018 17:57:58 +0000 (18:57 +0100)
This breaks backwards compatibility some, making smoke colors brighters
than before. But it is also more correct this way.

intern/cycles/kernel/geom/geom_volume.h

index 6be448c4fa4c2a6e04ac43fc11149f5f942d89a8..286d898992e658b251f507c1ce9d7e6bc59b1176 100644 (file)
@@ -68,7 +68,13 @@ ccl_device float3 volume_attribute_float3(KernelGlobals *kg, const ShaderData *s
        if(dx) *dx = make_float3(0.0f, 0.0f, 0.0f);
        if(dy) *dy = make_float3(0.0f, 0.0f, 0.0f);
 
-       return float4_to_float3(r);
+       if(r.w != 0.0f && r.w != 1.0f) {
+               /* For RGBA colors, unpremultiply after interpolation. */
+               return float4_to_float3(r) / r.w;
+       }
+       else {
+               return float4_to_float3(r);
+       }
 }
 
 #endif