diff options
Diffstat (limited to 'intern/cycles/render')
-rw-r--r-- | intern/cycles/render/attribute.cpp | 10 | ||||
-rw-r--r-- | intern/cycles/render/attribute.h | 2 | ||||
-rw-r--r-- | intern/cycles/render/image.h | 2 | ||||
-rw-r--r-- | intern/cycles/render/mesh.cpp | 22 | ||||
-rw-r--r-- | intern/cycles/render/scene.h | 1 |
5 files changed, 32 insertions, 5 deletions
diff --git a/intern/cycles/render/attribute.cpp b/intern/cycles/render/attribute.cpp index 72781bb0f9b..8abf869a775 100644 --- a/intern/cycles/render/attribute.cpp +++ b/intern/cycles/render/attribute.cpp @@ -69,6 +69,15 @@ void Attribute::add(const float& f) buffer.push_back(data[i]); } +void Attribute::add(const uchar4& f) +{ + char *data = (char*)&f; + size_t size = sizeof(f); + + for(size_t i = 0; i < size; i++) + buffer.push_back(data[i]); +} + void Attribute::add(const float3& f) { char *data = (char*)&f; @@ -136,6 +145,7 @@ size_t Attribute::element_size(int numverts, int numtris, int numsteps, int numc size = numtris; break; case ATTR_ELEMENT_CORNER: + case ATTR_ELEMENT_CORNER_BYTE: size = numtris*3; break; case ATTR_ELEMENT_CURVE: diff --git a/intern/cycles/render/attribute.h b/intern/cycles/render/attribute.h index 9fc32db8444..f5227ebde52 100644 --- a/intern/cycles/render/attribute.h +++ b/intern/cycles/render/attribute.h @@ -68,6 +68,7 @@ public: float3 *data_float3() { return (float3*)data(); } float4 *data_float4() { return (float4*)data(); } float *data_float() { return (float*)data(); } + uchar4 *data_uchar4() { return (uchar4*)data(); } Transform *data_transform() { return (Transform*)data(); } VoxelAttribute *data_voxel() { return ( VoxelAttribute*)data(); } @@ -80,6 +81,7 @@ public: void add(const float& f); void add(const float3& f); + void add(const uchar4& f); void add(const Transform& f); void add(const VoxelAttribute& f); void add(const char *data); diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h index 8abf2a33d74..3eacfa7beed 100644 --- a/intern/cycles/render/image.h +++ b/intern/cycles/render/image.h @@ -29,7 +29,7 @@ CCL_NAMESPACE_BEGIN /* generic */ -#define TEX_NUM_IMAGES 95 +#define TEX_NUM_IMAGES 94 #define TEX_IMAGE_BYTE_START TEX_NUM_FLOAT_IMAGES /* extended gpu */ diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp index b6826f0066b..808db4fe5b2 100644 --- a/intern/cycles/render/mesh.cpp +++ b/intern/cycles/render/mesh.cpp @@ -745,7 +745,7 @@ void MeshManager::update_svm_attributes(Device *device, DeviceScene *dscene, Sce device->tex_alloc("__attributes_map", dscene->attributes_map); } -static void update_attribute_element_offset(Mesh *mesh, vector<float>& attr_float, vector<float4>& attr_float3, +static void update_attribute_element_offset(Mesh *mesh, vector<float>& attr_float, vector<float4>& attr_float3, vector<uchar4>& attr_uchar4, Attribute *mattr, TypeDesc& type, int& offset, AttributeElement& element) { if(mattr) { @@ -766,6 +766,15 @@ static void update_attribute_element_offset(Mesh *mesh, vector<float>& attr_floa VoxelAttribute *voxel_data = mattr->data_voxel(); offset = voxel_data->slot; } + if(mattr->element == ATTR_ELEMENT_CORNER_BYTE) { + uchar4 *data = mattr->data_uchar4(); + offset = attr_uchar4.size(); + + attr_uchar4.resize(attr_uchar4.size() + size); + + for(size_t k = 0; k < size; k++) + attr_uchar4[offset+k] = data[k]; + } else if(mattr->type == TypeDesc::TypeFloat) { float *data = mattr->data_float(); offset = attr_float.size(); @@ -802,7 +811,7 @@ static void update_attribute_element_offset(Mesh *mesh, vector<float>& attr_floa offset -= mesh->vert_offset; else if(element == ATTR_ELEMENT_FACE) offset -= mesh->tri_offset; - else if(element == ATTR_ELEMENT_CORNER) + else if(element == ATTR_ELEMENT_CORNER || element == ATTR_ELEMENT_CORNER_BYTE) offset -= 3*mesh->tri_offset; else if(element == ATTR_ELEMENT_CURVE) offset -= mesh->curve_offset; @@ -843,6 +852,7 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene, * maps next */ vector<float> attr_float; vector<float4> attr_float3; + vector<uchar4> attr_uchar4; for(size_t i = 0; i < scene->meshes.size(); i++) { Mesh *mesh = scene->meshes[i]; @@ -863,10 +873,10 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene, memcpy(triangle_mattr->data_float3(), &mesh->verts[0], sizeof(float3)*mesh->verts.size()); } - update_attribute_element_offset(mesh, attr_float, attr_float3, triangle_mattr, + update_attribute_element_offset(mesh, attr_float, attr_float3, attr_uchar4, triangle_mattr, req.triangle_type, req.triangle_offset, req.triangle_element); - update_attribute_element_offset(mesh, attr_float, attr_float3, curve_mattr, + update_attribute_element_offset(mesh, attr_float, attr_float3, attr_uchar4, curve_mattr, req.curve_type, req.curve_offset, req.curve_element); if(progress.get_cancel()) return; @@ -892,6 +902,10 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene, dscene->attributes_float3.copy(&attr_float3[0], attr_float3.size()); device->tex_alloc("__attributes_float3", dscene->attributes_float3); } + if(attr_uchar4.size()) { + dscene->attributes_uchar4.copy(&attr_uchar4[0], attr_uchar4.size()); + device->tex_alloc("__attributes_uchar4", dscene->attributes_uchar4); + } } void MeshManager::device_update_mesh(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress) diff --git a/intern/cycles/render/scene.h b/intern/cycles/render/scene.h index 777d26ac79e..e5c7444c92d 100644 --- a/intern/cycles/render/scene.h +++ b/intern/cycles/render/scene.h @@ -85,6 +85,7 @@ public: device_vector<uint4> attributes_map; device_vector<float> attributes_float; device_vector<float4> attributes_float3; + device_vector<uchar4> attributes_uchar4; /* lights */ device_vector<float4> light_distribution; |