Shader Mixer: any easy way to rotate ST?
![Oso3D](https://farnsworth-prod.uc.r.appspot.com/forums/uploads/userpics/964/nKUSSXH2JM34Y.jpg)
So the Texture Coordinate Info... I'm working with the Tile brick, and I'd REALLY like some way to rotate the pattern. I'm wondering if there's a way to remap or otherwise move the coordinates from ST.
You currently have no notifications.
So the Texture Coordinate Info... I'm working with the Tile brick, and I'd REALLY like some way to rotate the pattern. I'm wondering if there's a way to remap or otherwise move the coordinates from ST.
Licensing Agreement | Terms of Service | Privacy Policy | EULA
© 2025 Daz Productions Inc. All Rights Reserved.
Comments
Hi, if you look here https://www.daz3d.com/forums/discussion/25448/list-of-shader-mixer-tutorials-and-recipes-wip-please-be-patient-as-i-update-the-list-thanks/p5
and scroll down to Eustace's post he has a link to a rotate brick based on Zigraphix's formula. It's the only way I know to rotate a tile in Shadermixer that I know of.
Sorry I didn't link directly to the post. I wasn't quite sure how to...
I appreciate any help! 90% of the time nobody knows anything. ;)
Hope it was useful...
It wasn't, because it's RSL and not MDL, but I forgot to specify that that's what I was talking about so that's on me. :/
Anyone know of something useful for MDL?
Only thing I can think of is to do it mathematically (using sin/cos) to determine ST offsets based on a rotation angle and then use those to index into the texture.
Sorry to hear that...I'm not as familiar with the MDL bricks yet.
http://www.migenius.com/doc/realityserver/4.3/resources/general/iray/mdl/base_module/index.html
Not sure if that is helpful, never tried building for iray in studio yet, but I found this in my bookmarks.
I thought that was what the 3Delight version did
I have no idea how to do that. ;)
TheKD: No idea how to apply any of that.
ah well
Will,
A texture exists, as you know, in UV coordinate space. U and V are clamped to [ 0.0, 1.0 ], so if you want to rotate about an arbitrary angle around the center of the texture:
Find the current UV point of the surface in question. Say it maps to (0.4, 0.7) on the texture. But you want to rotate the texture by 60° (positive angles are clockwise). How to find the right coordinates?
First, center them on the map. Subtract 0.5 from each coordinate, resulting in (-0.1, 0.2) as the desired offset from center point. Now since we want to rotate the TEXTURE clockwise by 60°, we want to find the new point by rotating the point counter-clockwise. So we negate the rotation angle, so we now use -60°.
Now, we want to convert the current coordinate into POLAR format, so instead of (u,v) we will have (r, Θ)....converting from rectangular to polar is pretty straightforward. r is √(u² + v²) and Θ is inv_tan(v/u). So (0.2236, -63.435°).
Now we just add the rotation amount (-60°) to Θ, and get our new value: (0.2236, -123.435°).
Now we convert back to rectangular coordinates, where u = r cos Θ and u = r sin Θ, so (-0.1232, -0.1866).
Now we just convert back to non-centered by adding 0.5 to each coordinate, giving us our new UV coordinate of (0.3768, 0.3134).
Now just retrive the pixel value for that UV from the map, and you have your 'rotated' map texture.
But, that may not be necessary. The MDL specs show a transform_coordinate method, which takes a 4x4 transformation matrix and a texture_coordinate_info struct. By specifiying the texture coordinate info to be uvw coords, and applying a rotation matrix (you can get the 4x4 transformation matrix from rotation_translation_scale method.) Now, the info on those is actual MDL from the link @TheKD linked to, and may be a bit out of date. But something should be available. You just won't find a simple 'rotate texture' block. You'll have to pull a lower-level file_texture object, and pass the surface UV coordinates through the transform coordinate stuff, then use those as the inputs to the file_texture in a new texture_coordinate_info struct.
I want to rotate the output of the Tile brick, which generates something that looks a bit like brick.
There's no texture...
Will, it's your lucky day. Decided to give it a shot. And here's the basic ShaderMixer tree, attached. Tested it, it works. Rotation parameter is in Radians, NOT Degrees, if you want degrees, you'll have to do a little math in between the UserParameters "Rotation" output and the input to the Z of the Float3 block (i.e., multiply the 'degrees' coming from the UserParameters by π/180).
Here's the Shader Mixer tree:
Also, I attached three images, each a simple plane with Z as the normal axis (you'll note in the mixer tree, we are using rotation around Z, X & Y are left at zero). First is at zero rotation, then 45°, and then at 90° (0, 0.753r, and 1.5704r)
I know this is just a Tiled Texture, not the Tile brick, but as long as it is producing a texture_coordinate_info, you should be able to do something along the same lines as the above.
Thank you kindly! I'll have to see if I can get it working with the tile thing, and if so... it'll be _amazingly_ more functional.
In my WTP3 I have a fairly flexible brick/tile thing. But I ran into problems with architecture because the default flow of the pattern would, say, go vertical rather than horizontal, which just wouldn't look right. (You can manipulate that with decals, but then you run into problems with windows amidst masonry)
I serched around texture cordinate blick which include rotation for MD not only trasnlate or scale, (like cycles texuter cordinate),but could not. then almost gave up.
thanks much,, yours teach me MDL blick to controll texutre cordinate more flexible.![smiley smiley](https://www.daz3d.com/forums/plugins/ckeditor/js/ckeditor/plugins/smiley/images/regular_smile.png)
When you apply a transform (i.e., the rotation_translation_scale block) it affects the coordinates based on order, not name.....in otherwords, while the label on the brick was Z, since it was being used to transform texture coordinates, the coordinates were UVW.....so I was rotating around W (which means the UV plane rotates.) So this SHOULD work correctly for you.
But we REALLY need some form of search box in the shader mixer......finding all those bricks when you know WHAT you need, but aren't sure WHICH category it is under takes for freaking EVER! The ability to filter on output and/or input types would be nice too.....
I also noticed a bunch of new bricks in MDL.....I haven't played with the ShaderMixer much since 4.9 dropped, so I haven't really experimented with some of these new bricks.....Going to play with some of them today. GradFlow2 looks interesting......
Yes, the lack of search... maaaaan.
'Glancing tint' is a weird cool one, and allowed me to build my Outline shader (which works pretty well... not perfect, but hey)
What's horrible is how often I'd spend 30 minutes trying to find a brick I had used before. Having to memorize the categorization of bricks is nuts.
OMG HPHOENIX THAT DID THE TRICK I LOVE YOU! You can have half of the proceeds from my free procedural pack!
Well, ok, warm fuzzies, anyway.
Woot! Glad it helped!
And I can use all the warm fuzzies I can get. :)
(a mention in the readme wouldn't hurt either!)
Ugh. 2+ hours playing with Grad Flow2 brick and nothing. Can't seem to find anything on it. No docs anywhere. Never seem to get anything but (0,0) out of it.
Trying to get access to the MDL documentation at the nVidia Developer Portal, but who knows how long that may take. :(
(And right-clicking the brick in the ShaderMixer list and selecting 'online help' just takes you to a non-existent page in the docs. DAZ really needs to get basic documentation of SOME kind available to us....)
Generating the shaders in my pack were a stressful nightmare.
thankfully, there is a learning curve, however brutal. :)
thanks hphoenix...I'm going to link to this from the Shadermixer thread. Great stuff!