diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2013-12-31 20:33:55 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2013-12-31 20:38:26 +0400 |
commit | 9cd2b199994ba48f343a89a270827b2e0ed3221d (patch) | |
tree | a90b3f0b2a5a8869b0fb8552a8d660d3d91209c1 /intern/cycles/render/attribute.cpp | |
parent | 6b03f92aa7bdb10cfde99bc30a7337c843bda57c (diff) |
Cycles Volume Render: generated texture coordinates for volume render.
This does not support staying fixed while the surface deforms, but for static
meshes it should match up with the surface texture coordinates. Implemented
as a matrix transform from objects space to mesh texture space.
Making this work for deforming surfaces would be quite complicated, you might
need something like harmonic coordinates as used in the mesh deform modifier,
probably will not be possible anytime soon.
Diffstat (limited to 'intern/cycles/render/attribute.cpp')
-rw-r--r-- | intern/cycles/render/attribute.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/intern/cycles/render/attribute.cpp b/intern/cycles/render/attribute.cpp index 6640439eca9..61b9cf2f3bc 100644 --- a/intern/cycles/render/attribute.cpp +++ b/intern/cycles/render/attribute.cpp @@ -19,6 +19,7 @@ #include "util_debug.h" #include "util_foreach.h" +#include "util_transform.h" CCL_NAMESPACE_BEGIN @@ -34,7 +35,7 @@ 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::TypeNormal || type == TypeDesc::TypeMatrix); } void Attribute::reserve(int numverts, int numtris, int numcurves, int numkeys) @@ -60,10 +61,21 @@ void Attribute::add(const float3& f) buffer.push_back(data[i]); } +void Attribute::add(const Transform& f) +{ + char *data = (char*)&f; + size_t size = sizeof(f); + + for(size_t i = 0; i < size; i++) + buffer.push_back(data[i]); +} + size_t Attribute::data_sizeof() const { if(type == TypeDesc::TypeFloat) return sizeof(float); + else if(type == TypeDesc::TypeMatrix) + return sizeof(Transform); else return sizeof(float3); } @@ -73,7 +85,8 @@ size_t Attribute::element_size(int numverts, int numtris, int numcurves, int num size_t size; switch(element) { - case ATTR_ELEMENT_VALUE: + case ATTR_ELEMENT_OBJECT: + case ATTR_ELEMENT_MESH: size = 1; break; case ATTR_ELEMENT_VERTEX: @@ -151,6 +164,8 @@ const char *Attribute::standard_name(AttributeStandard std) return "ptex_face_id"; else if(std == ATTR_STD_PTEX_UV) return "ptex_uv"; + else if(std == ATTR_STD_GENERATED_TRANSFORM) + return "generated_transform"; return ""; } @@ -256,6 +271,9 @@ Attribute *AttributeSet::add(AttributeStandard std, ustring name) case ATTR_STD_PTEX_UV: attr = add(name, TypeDesc::TypePoint, ATTR_ELEMENT_VERTEX); break; + case ATTR_STD_GENERATED_TRANSFORM: + attr = add(name, TypeDesc::TypeMatrix, ATTR_ELEMENT_MESH); + break; default: assert(0); break; @@ -274,6 +292,9 @@ Attribute *AttributeSet::add(AttributeStandard std, ustring name) case ATTR_STD_CURVE_INTERCEPT: attr = add(name, TypeDesc::TypeFloat, ATTR_ELEMENT_CURVE_KEY); break; + case ATTR_STD_GENERATED_TRANSFORM: + attr = add(name, TypeDesc::TypeMatrix, ATTR_ELEMENT_MESH); + break; default: assert(0); break; |