Rotating in cop filter.
1608 10 2- NicTanghe
- Member
- 193 posts
- Joined: Dec. 2016
- Offline
Hello I`m trying to make a flakes normal map.
For this i need gradients applied with a random orientation on preferably the id of the cell noise node.
all of the rotation / transformation nodes dont seem to have an input for the thing that needs rotation.
This confuzes me.
Also i cant seem to find a node that allows you to reapply XY. the texture node could do thtat but it only works on images.
For this i need gradients applied with a random orientation on preferably the id of the cell noise node.
all of the rotation / transformation nodes dont seem to have an input for the thing that needs rotation.
This confuzes me.
Also i cant seem to find a node that allows you to reapply XY. the texture node could do thtat but it only works on images.
Edited by NicTanghe - Nov. 7, 2022 11:47:24
- jsmack
- Member
- 7785 posts
- Joined: Sept. 2011
- Offline
- NicTanghe
- Member
- 193 posts
- Joined: Dec. 2016
- Offline
- animatrix_
- Member
- 4517 posts
- Joined: Feb. 2012
- Offline
You can't change the positions of the pixels just like you can't change the position of voxels in volumes. You have to change the look up positions.
Here is how to apply swirl to an input image in COPs for example (Bilinear filtering in this example):
Here is how to apply swirl to an input image in COPs for example (Bilinear filtering in this example):
float mirror ( float p ) { return abs ( p - 2.0f * floor ( ( p + 1.0f ) / 2.0f ) ); } vector [ ] computeSamplePoints ( int quality; int xres; int yres ) { vector samples [ ]; int nsamples = quality; int tsamples = nsamples * nsamples; float n = 1.0f / ( 1.0f + tsamples ); for ( int i = 1; i <= tsamples; ++i ) { float y = i * n; float x = frac ( y * nsamples ); samples [ i - 1 ] = set ( ( x - 0.5f ) / xres, ( y - 0.5f ) / yres, 0 ); } return samples; } cop2 swirl ( float angle = 0; float r = 1; vector2 t = { 0.5, 0.5 }; int quality = 3; int filter = 1; int outside = 0 ) { float rx = 0.5 * r; float ry = 0.5 * r; float maxr = rx; float x = X - t.x; float y = Y - t.y; float sx = max ( 1, 1.0f * XRES / YRES ); float sy = max ( 1, 1.0f * YRES / XRES ); if ( XRES > YRES ) rx = 0.5 * r * min ( XRES, YRES ) / max ( XRES, YRES ); else ry = 0.5 * r * min ( XRES, YRES ) / max ( XRES, YRES ); int setSample = 0; vector sample = 0; vector samplePoints [ ] = computeSamplePoints ( quality, XRES, YRES ); foreach ( vector p; samplePoints ) { if ( ( x * x ) / ( rx * rx ) + ( y * y ) / ( ry * ry ) <= 1 ) { float xx = x * sx + p.x; float yy = y * sy + p.y; float amount = ( maxr - sqrt ( x * x * sx * sx + y * y * sy * sy ) ) / maxr; float theta = amount * amount * radians ( angle ); float s = sin ( theta ); float c = cos ( theta ); xx = c * x - s * y + t.x; yy = s * x + c * y + t.y; if ( outside == 0 ) { xx = mirror ( xx ); yy = mirror ( yy ); } if ( filter == 0 ) sample += cinput ( 0, PL, AI, xx % 1, yy % 1, F, "wrap", "streak" ); else if ( filter == 1 ) sample += binput ( 0, PL, AI, xx % 1, yy % 1, F, "wrap", "streak" ); else if ( filter == 2 ) sample += finput ( 0, PL, AI, xx % 1, yy % 1, F, "wrap", "streak" ); setSample = 1; } } if ( setSample ) assign ( Cr, Cg, Cb, sample / arraylength ( samplePoints ) ); }
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
- NicTanghe
- Member
- 193 posts
- Joined: Dec. 2016
- Offline
thx !
I’m having some problems logically deconstructing the code, though.
1. the computeSamplePoints definitions throws me the error,
I don't understand why I would get this error
So I can't get the code working.
2. I don't understand what the samples actually are. I would think, based on language, it's just taking every so many pixels instead of all of them.
3. the cop2 type is confusing to me and i also didn’t find any documentation on it
4. it's not really used in your code, but I can never figure out how to use inputs and outputs in the snippet node
Any further help is greatly appreciated.
I’m having some problems logically deconstructing the code, though.
1. the computeSamplePoints definitions throws me the error,
Syntax error, unexpected identifier, expecting ';'. (7,12)
I don't understand why I would get this error
So I can't get the code working.
2. I don't understand what the samples actually are. I would think, based on language, it's just taking every so many pixels instead of all of them.
3. the cop2 type is confusing to me and i also didn’t find any documentation on it
4. it's not really used in your code, but I can never figure out how to use inputs and outputs in the snippet node
Any further help is greatly appreciated.
Edited by NicTanghe - Nov. 8, 2022 13:59:45
- animatrix_
- Member
- 4517 posts
- Joined: Feb. 2012
- Offline
That function is for generating multiple sampling positions for supersampling:
https://en.wikipedia.org/wiki/Supersampling [en.wikipedia.org]
Sorry this code is not meant to be put inside a Snippet VOP. It's created using File -> New Asset -> VEX (COP).
I attached the HDA itself because it has HDA level parameters also. Some default COPs are created this way, i.e. Velocity Blur COP. You can tell this if the HDA has a button called Edit VEX Function.
https://en.wikipedia.org/wiki/Supersampling [en.wikipedia.org]
Sorry this code is not meant to be put inside a Snippet VOP. It's created using File -> New Asset -> VEX (COP).
I attached the HDA itself because it has HDA level parameters also. Some default COPs are created this way, i.e. Velocity Blur COP. You can tell this if the HDA has a button called Edit VEX Function.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
- jsmack
- Member
- 7785 posts
- Joined: Sept. 2011
- Offline
NicTanghe
thx !
I’m having some problems logically deconstructing the code, though.
1. the computeSamplePoints definitions throws me the error,Syntax error, unexpected identifier, expecting ';'. (7,12)
I don't understand why I would get this error
So I can't get the code working.
2. I don't understand what the samples actually are. I would think, based on language, it's just taking every so many pixels instead of all of them.
3. the cop2 type is confusing to me and i also didn’t find any documentation on it
4. it's not really used in your code, but I can never figure out how to use inputs and outputs in the snippet node
Any further help is greatly appreciated.
I thought you were making a normal map. Why do you want to displace the texture space?
- NicTanghe
- Member
- 193 posts
- Joined: Dec. 2016
- Offline
- tamte
- Member
- 8567 posts
- Joined: July 2007
- Offline
- NicTanghe
- Member
- 193 posts
- Joined: Dec. 2016
- Offline
- mestela
- Member
- 1742 posts
- Joined: May 2006
- Online
I've been playing with similar ideas, made a simple setup that might help.
https://www.tokeru.com/cgwiki/index.php?title=HoudiniCops#Cellnoise_with_rotated_gradients [www.tokeru.com]
https://www.tokeru.com/cgwiki/index.php?title=HoudiniCops#Cellnoise_with_rotated_gradients [www.tokeru.com]
-
- Quick Links