GallenWolf Posted April 3, 2007 Share Posted April 3, 2007 Hey everyone! I am projecting a still plate onto geometry, and would like to bake out the texture as I will be moving the geometry around, and possibly doing stretch and squash. I followed the instructions here: http://odforce.net/wiki/index.php/ShaderUnwrap But they only worked for uv unwrapped objects, once I added in the UVTexture SOP with a camera projecting, it renders with box artifacts in Mantra. In any case, observing the UV space, it seems that the UVTexture SOP modifies the uv space greatly. I don't want that, as I would like to touch up my baked textures later. Just thinking off my head, perhaps the UV texture sop isn't needed, just some new vex shader that will project the texture from camera/screen space onto the geometry, so that we can keep the UVUnwrapped layout? I've attached a file, one showing the baking working for a uv mapped cylinder, and not working for the box. Thanks! Alvin textureProjection.hip Quote Link to comment Share on other sites More sharing options...
GallenWolf Posted April 10, 2007 Author Share Posted April 10, 2007 (edited) Hey all! I finally got this working. I was going through the old Houdini 4 VEX tutorials, and found the tutorial on light and shadow shaders, and adapted the Spotlight projection map shader into a surface shader. Here's the code that I adapted, hope it works for you: #pragma hint map image surface GW_camera_map_per_pixel( string map = ""; vector uv = 0; // For debug ) { float uu,vv; vector pos; string gwString = "cam1"; if (map != "") { //pos = wo_space(P); //pos = toNDC(gwString, pos); pos = toNDC(P); uu = pos.x; vv = pos.y; Cf = texture(map, uu,vv); } else { Cf = {0,1,0}; //Cf = texture(map, uv.x,uv.y); // Debug purposes } } This is a shader, so it should be in shops. Pipe in the image that you wish to project from. It will project from a camera in the scene. i still haven't figured out how it chooses the camera, but I only had one camera and it was projecting from that viewpoint. More tests required here. If you render the scene, it should work exactly like the UVTexture sop with camera projection enabled. In order to bake out, ensure that you have unwrapped the object, on the vertices, not points. Then use the render command: mantra -u /obj/geo1 Note that when baking out textures, I had to set the render resolution of the Mantra ROP to the same aspect ratio of the textures I was projection. E.g. I was projecting a 1280x960 JPEG onto some low res geometry, so my output from my mantra rop has to be, e.g. 640x480, 320x240 etc. If I were to render using say 1k by 1k, it would somehow be distorted? Wierd. More investigation required here. But in anycase, the experiment seems to be a success! Disclaimer: If there is a better way of doing this, please let me know!! Edited April 10, 2007 by GallenWolf Quote Link to comment Share on other sites More sharing options...
GallenWolf Posted April 10, 2007 Author Share Posted April 10, 2007 Still doing some testing, and suddenly, when I use a square aspect ratio in my Mantra ROP, it actually works properly for no apparent reason?! Gah. 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.