Remap image from one uv to another

   1937   3   1
User Avatar
Member
55 posts
Joined: Nov. 2015
Offline
Hello,

I'm looking for a way to essentially implement texture baking in SOPs. I came up with the attached solution using uvsample on a map loaded to a grid object where each point represents a pixel in the desired texture resolution. For some reason this simple approach seems correct to me but doesn't work. Any idea what I'm doing wrong?

Attachments:
Projector.hipnc (425.2 KB)

User Avatar
Member
806 posts
Joined: Oct. 2016
Offline
Hi, anonymous user,

without having looked at your project, the general idea of a “baking” (reproduction) process is to imagine a virtual camera sitting “on the normal” of each (target) texture UV pixel over the (source) object and “attracting” (in the purest sense of the word) that single pixel.
What most people do wrong when reinventing that wheel is to either directly calculate one UV position from the other ad ignoring that you have to “cross over” the target UV map onto the source “virtual camera position” and only at render stage actually USE the source UV map - or they ignore different UV tile rotations (not doing a trace through a camera but trying to calculate the correct pixel offset only on UVs).

The standard approach is to x/y (or u/v) walk over the target UV map, calculate camera positions from P using those UV offsets, offset the camera slightly by the local normal and read the source (source-UV based) texture information (which may be interpolated).

Marc
---
Out of here. Being called a dick after having supported Houdini users for years is over my paygrade.
I will work for money, but NOT for "you have to provide people with free products" Indie-artists.
Good bye.
https://www.marc-albrecht.de [www.marc-albrecht.de]
User Avatar
Member
833 posts
Joined: Jan. 2018
Offline
SideFX Labs UV Transfer?
>>Kays
For my Houdini tutorials and more visit:
https://www.youtube.com/c/RightBrainedTutorials [www.youtube.com]
User Avatar
Member
55 posts
Joined: Nov. 2015
Offline
malbrecht
Hi, anonymous user,

without having looked at your project, the general idea of a “baking” (reproduction) process is to imagine a virtual camera sitting “on the normal” of each (target) texture UV pixel over the (source) object and “attracting” (in the purest sense of the word) that single pixel.
What most people do wrong when reinventing that wheel is to either directly calculate one UV position from the other ad ignoring that you have to “cross over” the target UV map onto the source “virtual camera position” and only at render stage actually USE the source UV map - or they ignore different UV tile rotations (not doing a trace through a camera but trying to calculate the correct pixel offset only on UVs).

The standard approach is to x/y (or u/v) walk over the target UV map, calculate camera positions from P using those UV offsets, offset the camera slightly by the local normal and read the source (source-UV based) texture information (which may be interpolated).

Marc


Thanks Marc. I didn’t take camera position into consideration since I have two sets of UVs already: one mapped from camera projection and the other geometrically as polar mapping. The idea of my wrangle node is for each UV value (represented by individual points in a 512x512 grid), I find the world position of that uv value on the surface of the object(using uvsample). I then use that position with another uvsample to find the second UV set’s value at this surface position. Finally I use that found value from the second UV set to assign the color value from the grid at that new position(uv space obviously) to my current uv position. Does that make any sense?

It seems first uvsample returns erroneous values if the uv attribute value exists in multiple positions which is obviously the case when doing camera projection(ie uv tiles overlap). Forcing uvsample to return a vector array doesn’t do anything either…I think that’s my problem. To test idea I tried mapping textures from a grid in orthographic projection to the same grid in orthographic projection as well and in this case it works as expected(nothing happens on the color map grid basically)

The goal at the end like you said to bake a 512x512 map from one uv mapping to another.

Regards,
IA
Edited by Eyecon - May 26, 2020 14:24:17
  • Quick Links