View Full Version : shading: vector pointing in increasing u/v direction
Gravedigger 04-27-2010, 11:11 PM hey guys
i'm writing a shader in RSL
i'm wondering if its possible to get a vector pointing in the direction where u/v increases most
imagine a river. i have an uv-layout so the left riverside has a u-value of 0 the right riverside a u-value of 1. at the same time the beginning of the river has a v-value of 0 the end a v-value of 1
what i'd like to do is to stretch a texture in "flowing-direction"
i hope i could make my problem clear
grs
Gravedigger
|
|
rendermaniac
04-28-2010, 08:51 AM
If you want to find out the curvature, you can get the second derivative of u or v (or more likely s or t). There is information on how to do this here:
http://studentpages.scad.edu/~mparro21/curvature/curvature.htm
http://www.affine.com/curvature.html
This works well on NURBs surfaces, but gets a little more tricky on subdivs and polygons.
Simon
Gravedigger
04-28-2010, 08:58 AM
hei rendermaniac
thanks a lot for your answer. i'm not looking for the curvature
i'd like to have a vector pointing in the flow direction. imagine a guy sitting on his boat on a river. the vector i'm looking for is the velocityvector of him
as i said i have setup the uv-layout like descriped above and i hope that it's possible to get this vector defined at every position of the river
grs
Gravedigger
rendermaniac
04-28-2010, 09:47 AM
Yeah - just noticed that.
You may be able to use dPdv*dv - dPdv gives you the direction and dv gives you the scale.
Again NURBs will work best.
Simon
Gravedigger
04-28-2010, 09:52 AM
hei simon
thanks a lot for your anwer. i'll try that this afternoon and report my results
grs
Gravedigger
noizFACTORY
04-29-2010, 05:17 AM
So if the river is flowing down the v direction, you would want to stretch your textures in the same direction?
-Sachin
Gravedigger
04-29-2010, 02:36 PM
hei Sachin
thanks for your anwer. this is what sounds pretty plausible but u and v are not vectors but scalars. this is why simon suggests to take the derivative which points to the greatest change which in this case is exactly the direction i was looking for
noizFACTORY
04-29-2010, 03:02 PM
hei Sachin
thanks for your anwer. this is what sounds pretty plausible but u and v are not vectors but scalars. this is why simon suggests to take the derivative which points to the greatest change which in this case is exactly the direction i was looking for
Yes, I was merely confirming if thats what you wanted to do. dPdu or dPdv is what you'll probably need to use to do this. Interesting shader though. I'd like to have a go at it too.
-Sachin
Gravedigger
04-29-2010, 03:04 PM
yeah i was playing around because i need a simple river in a project. stretching the fractal really adds a lot of detail
what i did is that the sides of the river are shifted slowly while the middle part of the river is shifted fast. this results in a nice dynamic V-shape. after a few secs the river starts to be stretched too much. this is where i use modulus to blend in a less stretched version. like this it looks pretty nice
if you guys have some other ideas please share :D
grs
Gravedigger
CGTalk Moderation
04-29-2010, 03:04 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.