diff options
author | Thomas Dinges <blender@dingto.org> | 2014-06-14 01:40:39 +0400 |
---|---|---|
committer | Thomas Dinges <blender@dingto.org> | 2014-06-14 01:40:54 +0400 |
commit | 0ce3a755f83b047f49f78da1729a73b56b9c9d55 (patch) | |
tree | 2223b355e1c994db2225cdf85860d9d9e652fb35 /intern/cycles/blender/blender_curves.cpp | |
parent | 7e205836884e892995105518791ab49816da37ef (diff) |
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.
Diffstat (limited to 'intern/cycles/blender/blender_curves.cpp')
-rw-r--r-- | intern/cycles/blender/blender_curves.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp index 22de7b64273..7b1a8ec0b15 100644 --- a/intern/cycles/blender/blender_curves.cpp +++ b/intern/cycles/blender/blender_curves.cpp @@ -42,7 +42,7 @@ void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData); void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData, float3 RotCam); void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int resolution); void ExportCurveTriangleUV(Mesh *mesh, ParticleCurveData *CData, int vert_offset, int resol, float3 *uvdata); -void ExportCurveTriangleVcol(Mesh *mesh, ParticleCurveData *CData, int vert_offset, int resol, float3 *fdata); +void ExportCurveTriangleVcol(Mesh *mesh, ParticleCurveData *CData, int vert_offset, int resol, uchar4 *cdata); ParticleCurveData::ParticleCurveData() { @@ -726,9 +726,9 @@ void ExportCurveTriangleUV(Mesh *mesh, ParticleCurveData *CData, int vert_offset } } -void ExportCurveTriangleVcol(Mesh *mesh, ParticleCurveData *CData, int vert_offset, int resol, float3 *fdata) +void ExportCurveTriangleVcol(Mesh *mesh, ParticleCurveData *CData, int vert_offset, int resol, uchar4 *cdata) { - if(fdata == NULL) + if(cdata == NULL) return; int vertexindex = vert_offset; @@ -740,17 +740,17 @@ void ExportCurveTriangleVcol(Mesh *mesh, ParticleCurveData *CData, int vert_offs for(int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1; curvekey++) { for(int section = 0; section < resol; section++) { - fdata[vertexindex] = color_srgb_to_scene_linear(CData->curve_vcol[curve]); + cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear(CData->curve_vcol[curve])); vertexindex++; - fdata[vertexindex] = color_srgb_to_scene_linear(CData->curve_vcol[curve]); + cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear(CData->curve_vcol[curve])); vertexindex++; - fdata[vertexindex] = color_srgb_to_scene_linear(CData->curve_vcol[curve]); + cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear(CData->curve_vcol[curve])); vertexindex++; - fdata[vertexindex] = color_srgb_to_scene_linear(CData->curve_vcol[curve]); + cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear(CData->curve_vcol[curve])); vertexindex++; - fdata[vertexindex] = color_srgb_to_scene_linear(CData->curve_vcol[curve]); + cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear(CData->curve_vcol[curve])); vertexindex++; - fdata[vertexindex] = color_srgb_to_scene_linear(CData->curve_vcol[curve]); + cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear(CData->curve_vcol[curve])); vertexindex++; } } @@ -923,13 +923,12 @@ void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool ObtainCacheParticleVcol(mesh, &b_mesh, &b_ob, &CData, !preview, vcol_num); if(primitive == CURVE_TRIANGLES) { - Attribute *attr_vcol = mesh->attributes.add( - ustring(l->name().c_str()), TypeDesc::TypeColor, ATTR_ELEMENT_CORNER); + ustring(l->name().c_str()), TypeDesc::TypeColor, ATTR_ELEMENT_CORNER_BYTE); - float3 *fdata = attr_vcol->data_float3(); + uchar4 *cdata = attr_vcol->data_uchar4(); - ExportCurveTriangleVcol(mesh, &CData, tri_num * 3, used_res, fdata); + ExportCurveTriangleVcol(mesh, &CData, tri_num * 3, used_res, cdata); } else { Attribute *attr_vcol = mesh->curve_attributes.add( |