diff options
author | Stefan Werner <stefan.werner@tangent-animation.com> | 2019-03-05 17:06:09 +0300 |
---|---|---|
committer | Stefan Werner <stefan.werner@tangent-animation.com> | 2019-03-05 17:06:09 +0300 |
commit | c891fb2fbe99362ac8f3ff0821b32b84566f8f1c (patch) | |
tree | e410c45d5413058780cc6ae6b1a5033c80386c22 /intern/cycles/render | |
parent | cb7e66737d2d2d0628dda49ddb7d5541915d017b (diff) | |
parent | db7f9a70b0addd17a2f8a8d87c0b4d77d78b536e (diff) |
Merge branch 'blender2.7'
Diffstat (limited to 'intern/cycles/render')
-rw-r--r-- | intern/cycles/render/attribute.cpp | 5 | ||||
-rw-r--r-- | intern/cycles/render/attribute.h | 3 | ||||
-rw-r--r-- | intern/cycles/render/mesh.cpp | 37 | ||||
-rw-r--r-- | intern/cycles/render/mesh_subdivision.cpp | 7 | ||||
-rw-r--r-- | intern/cycles/render/nodes.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/render/scene.cpp | 1 | ||||
-rw-r--r-- | intern/cycles/render/scene.h | 1 |
7 files changed, 53 insertions, 3 deletions
diff --git a/intern/cycles/render/attribute.cpp b/intern/cycles/render/attribute.cpp index ca167a7c722..70f75a4b573 100644 --- a/intern/cycles/render/attribute.cpp +++ b/intern/cycles/render/attribute.cpp @@ -48,7 +48,8 @@ void Attribute::set(ustring name_, TypeDesc type_, AttributeElement element_) /* string and matrix not supported! */ assert(type == TypeDesc::TypeFloat || type == TypeDesc::TypeColor || type == TypeDesc::TypePoint || type == TypeDesc::TypeVector || - type == TypeDesc::TypeNormal || type == TypeDesc::TypeMatrix); + type == TypeDesc::TypeNormal || type == TypeDesc::TypeMatrix || + type == TypeFloat2); } void Attribute::resize(Mesh *mesh, AttributePrimitive prim, bool reserve_only) @@ -400,7 +401,7 @@ Attribute *AttributeSet::add(AttributeStandard std, ustring name) attr = add(name, TypeDesc::TypeNormal, ATTR_ELEMENT_FACE); break; case ATTR_STD_UV: - attr = add(name, TypeDesc::TypePoint, ATTR_ELEMENT_CORNER); + attr = add(name, TypeFloat2, ATTR_ELEMENT_CORNER); break; case ATTR_STD_UV_TANGENT: attr = add(name, TypeDesc::TypeVector, ATTR_ELEMENT_CORNER); diff --git a/intern/cycles/render/attribute.h b/intern/cycles/render/attribute.h index e7438f4513d..9a92d98b713 100644 --- a/intern/cycles/render/attribute.h +++ b/intern/cycles/render/attribute.h @@ -67,6 +67,7 @@ public: size_t buffer_size(Mesh *mesh, AttributePrimitive prim) const; char *data() { return (buffer.size())? &buffer[0]: NULL; }; + float2 *data_float2() { return (float2*)data(); } float3 *data_float3() { return (float3*)data(); } float4 *data_float4() { return (float4*)data(); } float *data_float() { return (float*)data(); } @@ -75,6 +76,7 @@ public: VoxelAttribute *data_voxel() { return ( VoxelAttribute*)data(); } const char *data() const { return (buffer.size())? &buffer[0]: NULL; } + const float2 *data_float2() const { return (const float2*)data(); } const float3 *data_float3() const { return (const float3*)data(); } const float4 *data_float4() const { return (const float4*)data(); } const float *data_float() const { return (const float*)data(); } @@ -85,6 +87,7 @@ public: void add_with_weight(void* dst, void* src, float weight); void add(const float& f); + void add(const float2& f); void add(const float3& f); void add(const uchar4& f); void add(const Transform& f); diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp index 955fa390e06..f0b06a1e14a 100644 --- a/intern/cycles/render/mesh.cpp +++ b/intern/cycles/render/mesh.cpp @@ -1209,6 +1209,8 @@ void MeshManager::update_osl_attributes(Device *device, Scene *scene, vector<Att osl_attr.type = TypeDesc::TypeFloat; else if(req.triangle_type == TypeDesc::TypeMatrix) osl_attr.type = TypeDesc::TypeMatrix; + else if(req.triangle_type == TypeFloat2) + osl_attr.type = TypeFloat2; else osl_attr.type = TypeDesc::TypeColor; @@ -1318,6 +1320,8 @@ void MeshManager::update_svm_attributes(Device *, DeviceScene *dscene, Scene *sc attr_map[index].w = NODE_ATTR_FLOAT; else if(req.triangle_type == TypeDesc::TypeMatrix) attr_map[index].w = NODE_ATTR_MATRIX; + else if(req.triangle_type == TypeFloat2) + attr_map[index].w = NODE_ATTR_FLOAT2; else attr_map[index].w = NODE_ATTR_FLOAT3; @@ -1335,6 +1339,8 @@ void MeshManager::update_svm_attributes(Device *, DeviceScene *dscene, Scene *sc attr_map[index].w = NODE_ATTR_FLOAT; else if(req.curve_type == TypeDesc::TypeMatrix) attr_map[index].w = NODE_ATTR_MATRIX; + else if(req.curve_type == TypeFloat2) + attr_map[index].w = NODE_ATTR_FLOAT2; else attr_map[index].w = NODE_ATTR_FLOAT3; @@ -1352,6 +1358,8 @@ void MeshManager::update_svm_attributes(Device *, DeviceScene *dscene, Scene *sc attr_map[index].w = NODE_ATTR_FLOAT; else if(req.subd_type == TypeDesc::TypeMatrix) attr_map[index].w = NODE_ATTR_MATRIX; + else if(req.subd_type == TypeFloat2) + attr_map[index].w = NODE_ATTR_FLOAT2; else attr_map[index].w = NODE_ATTR_FLOAT3; @@ -1380,6 +1388,7 @@ static void update_attribute_element_size(Mesh *mesh, Attribute *mattr, AttributePrimitive prim, size_t *attr_float_size, + size_t *attr_float2_size, size_t *attr_float3_size, size_t *attr_uchar4_size) { @@ -1395,6 +1404,9 @@ static void update_attribute_element_size(Mesh *mesh, else if(mattr->type == TypeDesc::TypeFloat) { *attr_float_size += size; } + else if(mattr->type == TypeFloat2) { + *attr_float2_size += size; + } else if(mattr->type == TypeDesc::TypeMatrix) { *attr_float3_size += size * 4; } @@ -1407,6 +1419,8 @@ static void update_attribute_element_size(Mesh *mesh, static void update_attribute_element_offset(Mesh *mesh, device_vector<float>& attr_float, size_t& attr_float_offset, + device_vector<float2>& attr_float2, + size_t& attr_float2_offset, device_vector<float4>& attr_float3, size_t& attr_float3_offset, device_vector<uchar4>& attr_uchar4, @@ -1453,6 +1467,16 @@ static void update_attribute_element_offset(Mesh *mesh, } attr_float_offset += size; } + else if(mattr->type == TypeFloat2) { + float2 *data = mattr->data_float2(); + offset = attr_float2_offset; + + assert(attr_float2.size() >= offset + size); + for(size_t k = 0; k < size; k++) { + attr_float2[offset+k] = data[k]; + } + attr_float2_offset += size; + } else if(mattr->type == TypeDesc::TypeMatrix) { Transform *tfm = mattr->data_transform(); offset = attr_float3_offset; @@ -1537,6 +1561,7 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene, * take 2x of overall attribute memory usage. */ size_t attr_float_size = 0; + size_t attr_float2_size = 0; size_t attr_float3_size = 0; size_t attr_uchar4_size = 0; for(size_t i = 0; i < scene->meshes.size(); i++) { @@ -1551,28 +1576,33 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene, triangle_mattr, ATTR_PRIM_TRIANGLE, &attr_float_size, + &attr_float2_size, &attr_float3_size, &attr_uchar4_size); update_attribute_element_size(mesh, curve_mattr, ATTR_PRIM_CURVE, &attr_float_size, + &attr_float2_size, &attr_float3_size, &attr_uchar4_size); update_attribute_element_size(mesh, subd_mattr, ATTR_PRIM_SUBD, &attr_float_size, + &attr_float2_size, &attr_float3_size, &attr_uchar4_size); } } dscene->attributes_float.alloc(attr_float_size); + dscene->attributes_float2.alloc(attr_float2_size); dscene->attributes_float3.alloc(attr_float3_size); dscene->attributes_uchar4.alloc(attr_uchar4_size); size_t attr_float_offset = 0; + size_t attr_float2_offset = 0; size_t attr_float3_offset = 0; size_t attr_uchar4_offset = 0; @@ -1590,6 +1620,7 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene, update_attribute_element_offset(mesh, dscene->attributes_float, attr_float_offset, + dscene->attributes_float2, attr_float2_offset, dscene->attributes_float3, attr_float3_offset, dscene->attributes_uchar4, attr_uchar4_offset, triangle_mattr, @@ -1599,6 +1630,7 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene, update_attribute_element_offset(mesh, dscene->attributes_float, attr_float_offset, + dscene->attributes_float2, attr_float2_offset, dscene->attributes_float3, attr_float3_offset, dscene->attributes_uchar4, attr_uchar4_offset, curve_mattr, @@ -1608,6 +1640,7 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene, update_attribute_element_offset(mesh, dscene->attributes_float, attr_float_offset, + dscene->attributes_float2, attr_float2_offset, dscene->attributes_float3, attr_float3_offset, dscene->attributes_uchar4, attr_uchar4_offset, subd_mattr, @@ -1633,6 +1666,9 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene, if(dscene->attributes_float.size()) { dscene->attributes_float.copy_to_device(); } + if(dscene->attributes_float2.size()) { + dscene->attributes_float2.copy_to_device(); + } if(dscene->attributes_float3.size()) { dscene->attributes_float3.copy_to_device(); } @@ -2265,6 +2301,7 @@ void MeshManager::device_free(Device *device, DeviceScene *dscene) dscene->patches.free(); dscene->attributes_map.free(); dscene->attributes_float.free(); + dscene->attributes_float2.free(); dscene->attributes_float3.free(); dscene->attributes_uchar4.free(); diff --git a/intern/cycles/render/mesh_subdivision.cpp b/intern/cycles/render/mesh_subdivision.cpp index 13fda99e9cc..95cc6f1fca1 100644 --- a/intern/cycles/render/mesh_subdivision.cpp +++ b/intern/cycles/render/mesh_subdivision.cpp @@ -231,6 +231,9 @@ public: if(attr.same_storage(attr.type, TypeDesc::TypeFloat)) { primvar_refiner.Interpolate(i+1, (OsdValue<float>*)src, (OsdValue<float>*&)dest); } + else if(attr.same_storage(attr.type, TypeFloat2)) { + primvar_refiner.Interpolate(i+1, (OsdValue<float2>*)src, (OsdValue<float2>*&)dest); + } else { primvar_refiner.Interpolate(i+1, (OsdValue<float4>*)src, (OsdValue<float4>*&)dest); } @@ -243,6 +246,10 @@ public: patch_table->ComputeLocalPointValues((OsdValue<float>*)&attr.buffer[0], (OsdValue<float>*)&attr.buffer[num_refiner_verts * attr.data_sizeof()]); } + else if(attr.same_storage(attr.type, TypeFloat2)) { + patch_table->ComputeLocalPointValues((OsdValue<float2>*)&attr.buffer[0], + (OsdValue<float2>*)&attr.buffer[num_refiner_verts * attr.data_sizeof()]); + } else { patch_table->ComputeLocalPointValues((OsdValue<float4>*)&attr.buffer[0], (OsdValue<float4>*)&attr.buffer[num_refiner_verts * attr.data_sizeof()]); diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index b70bad810de..fcdfb62785a 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -3480,7 +3480,7 @@ void TextureCoordinateNode::compile(SVMCompiler& compiler) } else { int attr = compiler.attribute(ATTR_STD_UV); - compiler.add_node(attr_node, attr, compiler.stack_assign(out), NODE_ATTR_FLOAT3); + compiler.add_node(attr_node, attr, compiler.stack_assign(out), NODE_ATTR_FLOAT2); } } diff --git a/intern/cycles/render/scene.cpp b/intern/cycles/render/scene.cpp index 23233b4e29e..1f551f206ef 100644 --- a/intern/cycles/render/scene.cpp +++ b/intern/cycles/render/scene.cpp @@ -66,6 +66,7 @@ DeviceScene::DeviceScene(Device *device) camera_motion(device, "__camera_motion", MEM_TEXTURE), attributes_map(device, "__attributes_map", MEM_TEXTURE), attributes_float(device, "__attributes_float", MEM_TEXTURE), + attributes_float2(device, "__attributes_float2", MEM_TEXTURE), attributes_float3(device, "__attributes_float3", MEM_TEXTURE), attributes_uchar4(device, "__attributes_uchar4", MEM_TEXTURE), light_distribution(device, "__light_distribution", MEM_TEXTURE), diff --git a/intern/cycles/render/scene.h b/intern/cycles/render/scene.h index 69cbfe9a324..e43800fe5c4 100644 --- a/intern/cycles/render/scene.h +++ b/intern/cycles/render/scene.h @@ -98,6 +98,7 @@ public: /* attributes */ device_vector<uint4> attributes_map; device_vector<float> attributes_float; + device_vector<float2> attributes_float2; device_vector<float4> attributes_float3; device_vector<uchar4> attributes_uchar4; |