davidyannick Posted March 28, 2020 Share Posted March 28, 2020 Is there a way in Houdini (VEX or VOP) to rotate each uv tiles individually, like Blender Guru does in blender ? To break texture tiling, thanks for your help Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted March 28, 2020 Share Posted March 28, 2020 Hi David, you can do this in: SOPs using primitive's node rotate and attribute copy. VOPs feeding random values to UV position's rotate. VEX feeding random values to the rotate function. int seed = chi('seed'); vector pivot = primuv(0, 'uv', i@primnum, 0.5); float amount_n = rand(i@primnum, seed); float amount_pi = fit01(amount_n, -M_PI, M_PI); matrix3 m = ident(); rotate(m, amount_pi, {0,0,1}); v@uv = (v@uv - pivot) * m + pivot; rotate_UV_tiles.hipnc 3 1 Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted March 28, 2020 Share Posted March 28, 2020 Or if you want overlapping UVs, using maximum space and everything in one vertex wrangle: string grp = itoa(i@primnum); vector bb_prim = relbbox(0, grp, v@P).xzy; vector bb_center = bb_prim - {0.5, 0.5, 0.0}; float amount_n = rand(i@primnum); float amount_pi = fit01(amount_n, -M_PI, M_PI); v@uv = bb_center; matrix m = ident(); rotate(m, amount_pi, {0,0,1}); v@uv *= m; float diag = sqrt(0.5); v@uv = fit(v@uv, -diag, diag, 0.0, 1.0); Here are some screenshots showing what each paragraph is doing: rotate_UV_tiles_overlap.hipnc 1 Quote Link to comment Share on other sites More sharing options...
davidyannick Posted March 28, 2020 Author Share Posted March 28, 2020 Thanks for your help Quote Link to comment Share on other sites More sharing options...
Mzigaib Posted March 29, 2020 Share Posted March 29, 2020 That is really cool Konstantin thanks for that! Can you tell if there is also a easy way to do that regardless of the surface division like in a single poly plane like this - Rotate uv tile blender tutorial Thanks. Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted March 29, 2020 Share Posted March 29, 2020 Hi Michel, yes sure. I think we have already discussed this under the keyword "texture bombing". Quote Link to comment Share on other sites More sharing options...
Mzigaib Posted March 29, 2020 Share Posted March 29, 2020 1 hour ago, konstantin magnus said: Hi Michel, yes sure. I think we have already discussed this under the keyword "texture bombing". Yeah I am aware of texture bombing I was hoping that someone knew a simpler way to just rotate the udims independently like Andrew does in Blender. Thanks for the tip thou. Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted March 29, 2020 Share Posted March 29, 2020 I see. Here is a quick concept of a material shader which rotates a user-defined number of tiles across a UV map. It includes noise to cover up the seams a little. uv_tiles_noise.hipnc 3 Quote Link to comment Share on other sites More sharing options...
Mzigaib Posted March 30, 2020 Share Posted March 30, 2020 This so useful that it should be incorporated in Houdini. Quote Link to comment Share on other sites More sharing options...
davidyannick Posted March 31, 2020 Author Share Posted March 31, 2020 I have tried with an heighfield, but an heighfield as too many polygons, do you know another way to randomize uv or a simple application of texture bombiing for large terrains ? Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted March 31, 2020 Share Posted March 31, 2020 Which method are you referring to? What's your desired output (image texture, mantra shader, vertex colors)? Quote Link to comment Share on other sites More sharing options...
davidyannick Posted March 31, 2020 Author Share Posted March 31, 2020 20 minutes ago, konstantin magnus said: Which method are you referring to? What's your desired output (image texture, mantra shader, vertex colors)? I've tried the method with overlapping uv, and I simply want to randomize the uv to break the tiling hdni_rendermanterrain.hiplc Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted March 31, 2020 Share Posted March 31, 2020 I guess the continuous grouping and building of bounding boxes has killed the performance. If it's quads only, you better try something like this instead: int vtx = vertexprimindex(0, i@vtxnum); v@uv.x = vtx == 0 || vtx == 1; v@uv.y = vtx == 0 || vtx == 3; v@uv -= set(0.5, 0.5, 0.0); float amount_n = rand(i@primnum, 123); float amount_pi = fit01(amount_n, -M_PI, M_PI); matrix m = ident(); rotate(m, amount_pi, {0,0,1}); v@uv *= m; float diag = sqrt(0.5); v@uv = fit(v@uv, -diag, diag, 0.0, 1.0); Quote Link to comment Share on other sites More sharing options...
velk Posted April 1, 2020 Share Posted April 1, 2020 (edited) Hey Konstantin, Your help came at the right time! I'm currently trying to achieve something very similar to David's example, but I need to restrict the rotation randomness to 90 degrees. I am familiar with some expressions to perform rotations in set increments, but not sure how to implement them with you code. I made a couple attempts but it just completely breaks your vex. The method that seems to work best with my setup is the 4-VEX UNIT. Much appreciated! Edited April 1, 2020 by velk Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted April 1, 2020 Share Posted April 1, 2020 Hi @velk, just cut the rotation amount values in half: float amount_n = rand(i@primnum) * 0.5; Or to get exact control over maximum degrees: float degrees = chf('max_degrees'); int vtx = vertexprimindex(0, i@vtxnum); v@uv.x = vtx == 0 || vtx == 1; v@uv.y = vtx == 0 || vtx == 3; v@uv -= set(0.5, 0.5, 0.0); float amount_n = rand(i@primnum, 123); float amount_rad = radians(degrees) * amount_n; matrix m = ident(); rotate(m, amount_rad, {0,0,1}); v@uv *= m; float diag = sqrt(0.5); v@uv = fit(v@uv, -diag, diag, 0.0, 1.0); 1 Quote Link to comment Share on other sites More sharing options...
velk Posted April 1, 2020 Share Posted April 1, 2020 (edited) Thanks @konstantin magnus It looks like this limits the maximum angle, however it also outputs any angle in-between. Is there a way to strictly enforce only 0, 90, 180, 270 degrees? I tried to adjust your random function and also played with the other methods you provided earlier (primitive, vop, vex) but I can't seem to achieve what I described. In the Vex method from your last post, I tried variations of this: float amount_n = (floor(rand($PT)*4)*90); In the Primitive method, I tried variations of this in the rotate Y field: floor((rand($PT)*2-1)*(360/90))*90 Cheers Edited April 1, 2020 by velk Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted April 1, 2020 Share Posted April 1, 2020 Hi @velk, does this work for you? int inc = chi('steps'); float degrees = chf('max_degrees'); int vtx = vertexprimindex(0, i@vtxnum); v@uv.x = vtx == 0 || vtx == 1; v@uv.y = vtx == 0 || vtx == 3; v@uv -= set(0.5, 0.5, 0.0); float amount_n = rand(i@primnum, 123); float amount_inc = floor(amount_n * inc) / float(inc); float amount_rad = radians(degrees) * amount_inc; matrix m = ident(); rotate(m, amount_rad, {0,0,1}); v@uv *= m; float diag = sqrt(0.5); v@uv = fit(v@uv, -diag, diag, 0.0, 1.0); Quote Link to comment Share on other sites More sharing options...
velk Posted April 1, 2020 Share Posted April 1, 2020 (edited) Hey @konstantin magnus Thanks for the fast reply! It still rotates at random orientations. See attached. I also tried with 90 and 90, and other values to test in the Max Degrees and Steps. Is there a way to perhaps get the code to pick between a list of values (0, 90, 180, 270) instead of random? Not the most flexible solution, but it would get the job done for simple scenarios. Edited April 1, 2020 by velk Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted April 1, 2020 Share Posted April 1, 2020 No no, just set steps to 4 and max_angle to 270°. 1 Quote Link to comment Share on other sites More sharing options...
velk Posted April 1, 2020 Share Posted April 1, 2020 Ahhhh got it! With 270, it still produces irregular angles. Looks like the correct combination is Max Degree: 360 and Steps: 4. Thanks again for your help with this! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.