Page MenuHome

Add UV Map node for Cycles
ClosedPublic

Authored by Kévin Dietrich (kevindietrich) on Jan 18 2014, 8:07 PM.

Diff Detail

Event Timeline

For now, it doesn't update when the UV map is changed. It stays tied to the active UV Map, if that makes sense.

How is that different from the Attribute node, which we already have?

For now it's not that different, I must agree. Some options are to be added like "From Dupli" and "UV Project", so that probably will make it different from the Attribute Node, I uploaded it for an initial review before tackling the rest, as it is my first development project (in or out of Blender). Then it's one of the quick hacks, so people must have had agreed on this.

Kévin Dietrich (kevindietrich) updated this revision to Unknown Object (????).Jan 18 2014, 9:51 PM

Added "From Dupli" and "UV Project" options.

Brecht Van Lommel (brecht) requested changes to this revision.Jan 19 2014, 3:49 PM

For how to do UV project, you can look for MA_MAPFLAG_UVPROJECT in shadeinput.c of Blender Internal. Then in kernel_triangle.h you can implement an attribute lookup function that works in a similar way.

What this is supposed to do is interpolate the UV coordinates in screen space instead of in world space. The code in shadeinput.c seems to be project the coordinates to screen space and then computing the barycentric coordinates u/v/l in the space, and then using those to interpolate the UV coordinates from the vertices.

It's not required to implemented that part, you can do it if you think it's interesting.

intern/cycles/render/nodes.cpp
2352

It doesn't take the UV map name into account because there's no code here to do that. ATTR_STD_UV just gives you the default UV map. To get an attribute by name you need to do the same as AttributeNode::compile if the uv map name != "".

Kévin Dietrich (kevindietrich) updated this revision to Unknown Object (????).Jan 22 2014, 7:23 PM

Fix map name input

Okay so now "From Dupli" doesn't work anymore, I did try to figure that out, I got some idea but I'd really like your feedback on this.

For "UV Project": I find this option interesting, but due to lack of time I won't do it now. I'll submit another patch later down the road (or revision to this diff if it's not committed by then), sounds good to you ? I still need to clean this diff from any mention of uv project.

Doing the projection in a separate patch sounds good to me.

I probably won't add this patch for 2.70, we're in bug fixing and polishing mode now, but I'll review this soon.

Kévin Dietrich (kevindietrich) updated this revision to Unknown Object (????).Jan 28 2014, 10:17 PM

Removed references to "UV Project"

Brecht Van Lommel (brecht) requested changes to this revision.Feb 4 2014, 6:34 PM

This looks good to me, except that the is no OSL shader for this node included.

Kévin Dietrich (kevindietrich) updated this revision to Unknown Object (????).Feb 5 2014, 9:53 PM

Add OSL shader

While writing the OSL shader, I ran into an issue: choosing the name of the uv map doesn't work. This also doesn't seem to work with the OSL Attribute node.

Kévin Dietrich (kevindietrich) updated this revision to Unknown Object (????).Feb 5 2014, 10:17 PM

Forgot to rebase with master

Looks good to me.

Ah well, so there remains an issue with OSL?

I haven't tried since then, but I couldn't get the Attribute node to work in OSL, at least inputing/changing the attribute name didn't do anything. And as I'm (kinda) reusing its code, then yes there might an issue with the getattribute() function. I'll go ahead and do some more testing to see if it's a bug or if my setup was wrong and I'll let you know.

OK, so something's wrong with OSL, here is the bug report: T39415.

Fixed the OSL part, will commit in a minute, thanks for the patch!