Cycles: Add support for uchar4 attributes.

* Added support for uchar4 attributes to Cycles' attribute system.
* This is used for Vertex Colors now, which saves some memory (4 unsigned characters, instead of 4 floats).
* GPU Texture Limit on sm_20 and sm_21 decreased from 95 to 94, because we need a new texture for the uchar4 attributes. This is no problem for sm_30 or newer.

Part of my GSoC 2014.
This commit is contained in:
Thomas Dinges
2014-06-13 23:40:39 +02:00
parent 7e20583688
commit 0ce3a755f8
12 changed files with 91 additions and 33 deletions

View File

@@ -259,11 +259,20 @@ ccl_device float3 triangle_attribute_float3(KernelGlobals *kg, const ShaderData
return sd->u*f0 + sd->v*f1 + (1.0f - sd->u - sd->v)*f2;
}
else if(elem == ATTR_ELEMENT_CORNER) {
else if(elem == ATTR_ELEMENT_CORNER || elem == ATTR_ELEMENT_CORNER_BYTE) {
int tri = offset + sd->prim*3;
float3 f0 = float4_to_float3(kernel_tex_fetch(__attributes_float3, tri + 0));
float3 f1 = float4_to_float3(kernel_tex_fetch(__attributes_float3, tri + 1));
float3 f2 = float4_to_float3(kernel_tex_fetch(__attributes_float3, tri + 2));
float3 f0, f1, f2;
if(elem == ATTR_ELEMENT_CORNER) {
f0 = float4_to_float3(kernel_tex_fetch(__attributes_float3, tri + 0));
f1 = float4_to_float3(kernel_tex_fetch(__attributes_float3, tri + 1));
f2 = float4_to_float3(kernel_tex_fetch(__attributes_float3, tri + 2));
}
else {
f0 = color_byte_to_float(kernel_tex_fetch(__attributes_uchar4, tri + 0));
f1 = color_byte_to_float(kernel_tex_fetch(__attributes_uchar4, tri + 1));
f2 = color_byte_to_float(kernel_tex_fetch(__attributes_uchar4, tri + 2));
}
#ifdef __RAY_DIFFERENTIALS__
if(dx) *dx = sd->du.dx*f0 + sd->dv.dx*f1 - (sd->du.dx + sd->dv.dx)*f2;