How to combine Bézier curves to a surface?
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
My aim is to smooth the terrain in a video game. Therefore I contrived an algorithm that makes use of Bézier curves of different orders. But this algorithm is defined in a two dimensional space for now.
To shift it into the third dimension I need to somehow combine the Bézier curves. Given two curves in each two dimensions, how can I combine them to build a surface?
I thought about something like a curve of a curve. Or maybe I could multiply them somehow. How can I combine them to cause the wanted behavior? Is there a common approach?
In the image you can see the input, on the left, and the output, on the right, of the algorithm that works in a two dimensional space. For the real application there is a three dimensional input.
The algorithm relays only on the adjacent tiles. Given these it will define the control points of the mentioned Bézier curve. Additionally it marks one side of the curve as inside the terrain and the other as outside.
3d bezier-curve
add a comment |Â
up vote
2
down vote
favorite
My aim is to smooth the terrain in a video game. Therefore I contrived an algorithm that makes use of Bézier curves of different orders. But this algorithm is defined in a two dimensional space for now.
To shift it into the third dimension I need to somehow combine the Bézier curves. Given two curves in each two dimensions, how can I combine them to build a surface?
I thought about something like a curve of a curve. Or maybe I could multiply them somehow. How can I combine them to cause the wanted behavior? Is there a common approach?
In the image you can see the input, on the left, and the output, on the right, of the algorithm that works in a two dimensional space. For the real application there is a three dimensional input.
The algorithm relays only on the adjacent tiles. Given these it will define the control points of the mentioned Bézier curve. Additionally it marks one side of the curve as inside the terrain and the other as outside.
3d bezier-curve
I am not so sure Bézier curves would be easy to fit. Easier would be some interpolation scheme, like cubic interpolation. I would try an inverse discrete wavelet transform interpreting as low-low-low frequency band. Potentially with applying some regularization. Or you could just build a big equation system where you push function values towards the edges and regularize for first and second order differentials. The last method is so powerful you can fuse the solution it to parametric functions like polynomials if you want to.
â mathreadler
Aug 19 at 8:02
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
My aim is to smooth the terrain in a video game. Therefore I contrived an algorithm that makes use of Bézier curves of different orders. But this algorithm is defined in a two dimensional space for now.
To shift it into the third dimension I need to somehow combine the Bézier curves. Given two curves in each two dimensions, how can I combine them to build a surface?
I thought about something like a curve of a curve. Or maybe I could multiply them somehow. How can I combine them to cause the wanted behavior? Is there a common approach?
In the image you can see the input, on the left, and the output, on the right, of the algorithm that works in a two dimensional space. For the real application there is a three dimensional input.
The algorithm relays only on the adjacent tiles. Given these it will define the control points of the mentioned Bézier curve. Additionally it marks one side of the curve as inside the terrain and the other as outside.
3d bezier-curve
My aim is to smooth the terrain in a video game. Therefore I contrived an algorithm that makes use of Bézier curves of different orders. But this algorithm is defined in a two dimensional space for now.
To shift it into the third dimension I need to somehow combine the Bézier curves. Given two curves in each two dimensions, how can I combine them to build a surface?
I thought about something like a curve of a curve. Or maybe I could multiply them somehow. How can I combine them to cause the wanted behavior? Is there a common approach?
In the image you can see the input, on the left, and the output, on the right, of the algorithm that works in a two dimensional space. For the real application there is a three dimensional input.
The algorithm relays only on the adjacent tiles. Given these it will define the control points of the mentioned Bézier curve. Additionally it marks one side of the curve as inside the terrain and the other as outside.
3d bezier-curve
edited Aug 19 at 8:04
mathreadler
13.8k71957
13.8k71957
asked Mar 18 '13 at 18:04
danijar
205113
205113
I am not so sure Bézier curves would be easy to fit. Easier would be some interpolation scheme, like cubic interpolation. I would try an inverse discrete wavelet transform interpreting as low-low-low frequency band. Potentially with applying some regularization. Or you could just build a big equation system where you push function values towards the edges and regularize for first and second order differentials. The last method is so powerful you can fuse the solution it to parametric functions like polynomials if you want to.
â mathreadler
Aug 19 at 8:02
add a comment |Â
I am not so sure Bézier curves would be easy to fit. Easier would be some interpolation scheme, like cubic interpolation. I would try an inverse discrete wavelet transform interpreting as low-low-low frequency band. Potentially with applying some regularization. Or you could just build a big equation system where you push function values towards the edges and regularize for first and second order differentials. The last method is so powerful you can fuse the solution it to parametric functions like polynomials if you want to.
â mathreadler
Aug 19 at 8:02
I am not so sure Bézier curves would be easy to fit. Easier would be some interpolation scheme, like cubic interpolation. I would try an inverse discrete wavelet transform interpreting as low-low-low frequency band. Potentially with applying some regularization. Or you could just build a big equation system where you push function values towards the edges and regularize for first and second order differentials. The last method is so powerful you can fuse the solution it to parametric functions like polynomials if you want to.
â mathreadler
Aug 19 at 8:02
I am not so sure Bézier curves would be easy to fit. Easier would be some interpolation scheme, like cubic interpolation. I would try an inverse discrete wavelet transform interpreting as low-low-low frequency band. Potentially with applying some regularization. Or you could just build a big equation system where you push function values towards the edges and regularize for first and second order differentials. The last method is so powerful you can fuse the solution it to parametric functions like polynomials if you want to.
â mathreadler
Aug 19 at 8:02
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
You can define a bezier-area by
$$x(lambda,mu) = sum^m_i=0sum^n_j=0B_im(lambda)B_jn(mu)p_ij$$
with
$lambda,muin[0,1]$, $B_im$ are the Bernstein polynomials and $p_ij$ are the given points.
Note: For this approach you need a grid of points.
add a comment |Â
up vote
1
down vote
I would not use Bezier curves for this. Too much work to find the end-points and you end up with a big clumsy polynomial.
I would build a linear least squares problem minimizing the gradient (smoothing the slopes of hills).
First let's split each pixel into $6times 6$ which will give the new smoothed resolution (just an example, you can pick any size you would like).
Now the optimization problem $$bf v_o = min_bf v _F^2+$$
where $bf d$ is the initial pixely blocky surface, and $bf v$ is the vector of smoothing change you want to do.
Already after 2 iterations of a very fast iterative solver we can get results like this:
After clarification from OP, I realized it is more this problem we have ( but in 3D ).
Now the contours (level sets) to this smoothed binary function can be used to create an interpolative effect:
Hey, thanks for the interesting answer after such a long time. I'm still sometimes thinking about this problem because I didn't come up with a satisfactory solution yet. One motivation of only considering the 26 neighboring cells for the shape of each block was that it will give make it easier for users to still infer the underlying block structure. It would also allow to precompute the meshes for common situations (for many of the $2^26$ possible neighborhoods the inner block is not visible). Could you think of a way to incorporate this constraint into your approach?
â danijar
Aug 25 at 13:46
Oh wow, I did not even look at the date when I posted but I see now. Yes I should maybe not have expected you were still looking for an answer. Ah so you have real 3D with three dimensional blocks and not just the height values for a surface of some solid object? Well you could apply the same approach in 3D, I think. Refine the mesh where you copy the values from the bigger mesh, and then minimize a 3D gradient and then threshold the result.
â mathreadler
Aug 25 at 13:57
Well, glad you posted! Yes, I have a 3D grid of binary values. My questions was if you can think of a way for the resulting mesh of each cell to only depend on the adjacent cells. This would be useful for many reasons. For example, it allows loading additional chunks once they come into view, without having to change the smoothing of the existing parts. I also suspect that a global optimization will be too slow for millions of blocks as used in the game.
â danijar
Aug 25 at 14:09
1
Ah ok. Yes for an exact solution it will be too slow. But this is computer graphics for entertainment and not safety critical software for medicine or something like that. Which means you can cheat with approximation as much you want as long as the result looks good ;) All iterative solvers will only be dependent on local values, you will need a maximum of a few iterations and they will basically be as fast as a couple of convolutions which is definitely fast enough.
â mathreadler
Aug 25 at 14:53
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
You can define a bezier-area by
$$x(lambda,mu) = sum^m_i=0sum^n_j=0B_im(lambda)B_jn(mu)p_ij$$
with
$lambda,muin[0,1]$, $B_im$ are the Bernstein polynomials and $p_ij$ are the given points.
Note: For this approach you need a grid of points.
add a comment |Â
up vote
2
down vote
accepted
You can define a bezier-area by
$$x(lambda,mu) = sum^m_i=0sum^n_j=0B_im(lambda)B_jn(mu)p_ij$$
with
$lambda,muin[0,1]$, $B_im$ are the Bernstein polynomials and $p_ij$ are the given points.
Note: For this approach you need a grid of points.
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
You can define a bezier-area by
$$x(lambda,mu) = sum^m_i=0sum^n_j=0B_im(lambda)B_jn(mu)p_ij$$
with
$lambda,muin[0,1]$, $B_im$ are the Bernstein polynomials and $p_ij$ are the given points.
Note: For this approach you need a grid of points.
You can define a bezier-area by
$$x(lambda,mu) = sum^m_i=0sum^n_j=0B_im(lambda)B_jn(mu)p_ij$$
with
$lambda,muin[0,1]$, $B_im$ are the Bernstein polynomials and $p_ij$ are the given points.
Note: For this approach you need a grid of points.
answered Mar 18 '13 at 18:17
Jakube
1,547818
1,547818
add a comment |Â
add a comment |Â
up vote
1
down vote
I would not use Bezier curves for this. Too much work to find the end-points and you end up with a big clumsy polynomial.
I would build a linear least squares problem minimizing the gradient (smoothing the slopes of hills).
First let's split each pixel into $6times 6$ which will give the new smoothed resolution (just an example, you can pick any size you would like).
Now the optimization problem $$bf v_o = min_bf v _F^2+$$
where $bf d$ is the initial pixely blocky surface, and $bf v$ is the vector of smoothing change you want to do.
Already after 2 iterations of a very fast iterative solver we can get results like this:
After clarification from OP, I realized it is more this problem we have ( but in 3D ).
Now the contours (level sets) to this smoothed binary function can be used to create an interpolative effect:
Hey, thanks for the interesting answer after such a long time. I'm still sometimes thinking about this problem because I didn't come up with a satisfactory solution yet. One motivation of only considering the 26 neighboring cells for the shape of each block was that it will give make it easier for users to still infer the underlying block structure. It would also allow to precompute the meshes for common situations (for many of the $2^26$ possible neighborhoods the inner block is not visible). Could you think of a way to incorporate this constraint into your approach?
â danijar
Aug 25 at 13:46
Oh wow, I did not even look at the date when I posted but I see now. Yes I should maybe not have expected you were still looking for an answer. Ah so you have real 3D with three dimensional blocks and not just the height values for a surface of some solid object? Well you could apply the same approach in 3D, I think. Refine the mesh where you copy the values from the bigger mesh, and then minimize a 3D gradient and then threshold the result.
â mathreadler
Aug 25 at 13:57
Well, glad you posted! Yes, I have a 3D grid of binary values. My questions was if you can think of a way for the resulting mesh of each cell to only depend on the adjacent cells. This would be useful for many reasons. For example, it allows loading additional chunks once they come into view, without having to change the smoothing of the existing parts. I also suspect that a global optimization will be too slow for millions of blocks as used in the game.
â danijar
Aug 25 at 14:09
1
Ah ok. Yes for an exact solution it will be too slow. But this is computer graphics for entertainment and not safety critical software for medicine or something like that. Which means you can cheat with approximation as much you want as long as the result looks good ;) All iterative solvers will only be dependent on local values, you will need a maximum of a few iterations and they will basically be as fast as a couple of convolutions which is definitely fast enough.
â mathreadler
Aug 25 at 14:53
add a comment |Â
up vote
1
down vote
I would not use Bezier curves for this. Too much work to find the end-points and you end up with a big clumsy polynomial.
I would build a linear least squares problem minimizing the gradient (smoothing the slopes of hills).
First let's split each pixel into $6times 6$ which will give the new smoothed resolution (just an example, you can pick any size you would like).
Now the optimization problem $$bf v_o = min_bf v _F^2+$$
where $bf d$ is the initial pixely blocky surface, and $bf v$ is the vector of smoothing change you want to do.
Already after 2 iterations of a very fast iterative solver we can get results like this:
After clarification from OP, I realized it is more this problem we have ( but in 3D ).
Now the contours (level sets) to this smoothed binary function can be used to create an interpolative effect:
Hey, thanks for the interesting answer after such a long time. I'm still sometimes thinking about this problem because I didn't come up with a satisfactory solution yet. One motivation of only considering the 26 neighboring cells for the shape of each block was that it will give make it easier for users to still infer the underlying block structure. It would also allow to precompute the meshes for common situations (for many of the $2^26$ possible neighborhoods the inner block is not visible). Could you think of a way to incorporate this constraint into your approach?
â danijar
Aug 25 at 13:46
Oh wow, I did not even look at the date when I posted but I see now. Yes I should maybe not have expected you were still looking for an answer. Ah so you have real 3D with three dimensional blocks and not just the height values for a surface of some solid object? Well you could apply the same approach in 3D, I think. Refine the mesh where you copy the values from the bigger mesh, and then minimize a 3D gradient and then threshold the result.
â mathreadler
Aug 25 at 13:57
Well, glad you posted! Yes, I have a 3D grid of binary values. My questions was if you can think of a way for the resulting mesh of each cell to only depend on the adjacent cells. This would be useful for many reasons. For example, it allows loading additional chunks once they come into view, without having to change the smoothing of the existing parts. I also suspect that a global optimization will be too slow for millions of blocks as used in the game.
â danijar
Aug 25 at 14:09
1
Ah ok. Yes for an exact solution it will be too slow. But this is computer graphics for entertainment and not safety critical software for medicine or something like that. Which means you can cheat with approximation as much you want as long as the result looks good ;) All iterative solvers will only be dependent on local values, you will need a maximum of a few iterations and they will basically be as fast as a couple of convolutions which is definitely fast enough.
â mathreadler
Aug 25 at 14:53
add a comment |Â
up vote
1
down vote
up vote
1
down vote
I would not use Bezier curves for this. Too much work to find the end-points and you end up with a big clumsy polynomial.
I would build a linear least squares problem minimizing the gradient (smoothing the slopes of hills).
First let's split each pixel into $6times 6$ which will give the new smoothed resolution (just an example, you can pick any size you would like).
Now the optimization problem $$bf v_o = min_bf v _F^2+$$
where $bf d$ is the initial pixely blocky surface, and $bf v$ is the vector of smoothing change you want to do.
Already after 2 iterations of a very fast iterative solver we can get results like this:
After clarification from OP, I realized it is more this problem we have ( but in 3D ).
Now the contours (level sets) to this smoothed binary function can be used to create an interpolative effect:
I would not use Bezier curves for this. Too much work to find the end-points and you end up with a big clumsy polynomial.
I would build a linear least squares problem minimizing the gradient (smoothing the slopes of hills).
First let's split each pixel into $6times 6$ which will give the new smoothed resolution (just an example, you can pick any size you would like).
Now the optimization problem $$bf v_o = min_bf v _F^2+$$
where $bf d$ is the initial pixely blocky surface, and $bf v$ is the vector of smoothing change you want to do.
Already after 2 iterations of a very fast iterative solver we can get results like this:
After clarification from OP, I realized it is more this problem we have ( but in 3D ).
Now the contours (level sets) to this smoothed binary function can be used to create an interpolative effect:
edited Aug 31 at 17:13
answered Aug 25 at 8:00
mathreadler
13.8k71957
13.8k71957
Hey, thanks for the interesting answer after such a long time. I'm still sometimes thinking about this problem because I didn't come up with a satisfactory solution yet. One motivation of only considering the 26 neighboring cells for the shape of each block was that it will give make it easier for users to still infer the underlying block structure. It would also allow to precompute the meshes for common situations (for many of the $2^26$ possible neighborhoods the inner block is not visible). Could you think of a way to incorporate this constraint into your approach?
â danijar
Aug 25 at 13:46
Oh wow, I did not even look at the date when I posted but I see now. Yes I should maybe not have expected you were still looking for an answer. Ah so you have real 3D with three dimensional blocks and not just the height values for a surface of some solid object? Well you could apply the same approach in 3D, I think. Refine the mesh where you copy the values from the bigger mesh, and then minimize a 3D gradient and then threshold the result.
â mathreadler
Aug 25 at 13:57
Well, glad you posted! Yes, I have a 3D grid of binary values. My questions was if you can think of a way for the resulting mesh of each cell to only depend on the adjacent cells. This would be useful for many reasons. For example, it allows loading additional chunks once they come into view, without having to change the smoothing of the existing parts. I also suspect that a global optimization will be too slow for millions of blocks as used in the game.
â danijar
Aug 25 at 14:09
1
Ah ok. Yes for an exact solution it will be too slow. But this is computer graphics for entertainment and not safety critical software for medicine or something like that. Which means you can cheat with approximation as much you want as long as the result looks good ;) All iterative solvers will only be dependent on local values, you will need a maximum of a few iterations and they will basically be as fast as a couple of convolutions which is definitely fast enough.
â mathreadler
Aug 25 at 14:53
add a comment |Â
Hey, thanks for the interesting answer after such a long time. I'm still sometimes thinking about this problem because I didn't come up with a satisfactory solution yet. One motivation of only considering the 26 neighboring cells for the shape of each block was that it will give make it easier for users to still infer the underlying block structure. It would also allow to precompute the meshes for common situations (for many of the $2^26$ possible neighborhoods the inner block is not visible). Could you think of a way to incorporate this constraint into your approach?
â danijar
Aug 25 at 13:46
Oh wow, I did not even look at the date when I posted but I see now. Yes I should maybe not have expected you were still looking for an answer. Ah so you have real 3D with three dimensional blocks and not just the height values for a surface of some solid object? Well you could apply the same approach in 3D, I think. Refine the mesh where you copy the values from the bigger mesh, and then minimize a 3D gradient and then threshold the result.
â mathreadler
Aug 25 at 13:57
Well, glad you posted! Yes, I have a 3D grid of binary values. My questions was if you can think of a way for the resulting mesh of each cell to only depend on the adjacent cells. This would be useful for many reasons. For example, it allows loading additional chunks once they come into view, without having to change the smoothing of the existing parts. I also suspect that a global optimization will be too slow for millions of blocks as used in the game.
â danijar
Aug 25 at 14:09
1
Ah ok. Yes for an exact solution it will be too slow. But this is computer graphics for entertainment and not safety critical software for medicine or something like that. Which means you can cheat with approximation as much you want as long as the result looks good ;) All iterative solvers will only be dependent on local values, you will need a maximum of a few iterations and they will basically be as fast as a couple of convolutions which is definitely fast enough.
â mathreadler
Aug 25 at 14:53
Hey, thanks for the interesting answer after such a long time. I'm still sometimes thinking about this problem because I didn't come up with a satisfactory solution yet. One motivation of only considering the 26 neighboring cells for the shape of each block was that it will give make it easier for users to still infer the underlying block structure. It would also allow to precompute the meshes for common situations (for many of the $2^26$ possible neighborhoods the inner block is not visible). Could you think of a way to incorporate this constraint into your approach?
â danijar
Aug 25 at 13:46
Hey, thanks for the interesting answer after such a long time. I'm still sometimes thinking about this problem because I didn't come up with a satisfactory solution yet. One motivation of only considering the 26 neighboring cells for the shape of each block was that it will give make it easier for users to still infer the underlying block structure. It would also allow to precompute the meshes for common situations (for many of the $2^26$ possible neighborhoods the inner block is not visible). Could you think of a way to incorporate this constraint into your approach?
â danijar
Aug 25 at 13:46
Oh wow, I did not even look at the date when I posted but I see now. Yes I should maybe not have expected you were still looking for an answer. Ah so you have real 3D with three dimensional blocks and not just the height values for a surface of some solid object? Well you could apply the same approach in 3D, I think. Refine the mesh where you copy the values from the bigger mesh, and then minimize a 3D gradient and then threshold the result.
â mathreadler
Aug 25 at 13:57
Oh wow, I did not even look at the date when I posted but I see now. Yes I should maybe not have expected you were still looking for an answer. Ah so you have real 3D with three dimensional blocks and not just the height values for a surface of some solid object? Well you could apply the same approach in 3D, I think. Refine the mesh where you copy the values from the bigger mesh, and then minimize a 3D gradient and then threshold the result.
â mathreadler
Aug 25 at 13:57
Well, glad you posted! Yes, I have a 3D grid of binary values. My questions was if you can think of a way for the resulting mesh of each cell to only depend on the adjacent cells. This would be useful for many reasons. For example, it allows loading additional chunks once they come into view, without having to change the smoothing of the existing parts. I also suspect that a global optimization will be too slow for millions of blocks as used in the game.
â danijar
Aug 25 at 14:09
Well, glad you posted! Yes, I have a 3D grid of binary values. My questions was if you can think of a way for the resulting mesh of each cell to only depend on the adjacent cells. This would be useful for many reasons. For example, it allows loading additional chunks once they come into view, without having to change the smoothing of the existing parts. I also suspect that a global optimization will be too slow for millions of blocks as used in the game.
â danijar
Aug 25 at 14:09
1
1
Ah ok. Yes for an exact solution it will be too slow. But this is computer graphics for entertainment and not safety critical software for medicine or something like that. Which means you can cheat with approximation as much you want as long as the result looks good ;) All iterative solvers will only be dependent on local values, you will need a maximum of a few iterations and they will basically be as fast as a couple of convolutions which is definitely fast enough.
â mathreadler
Aug 25 at 14:53
Ah ok. Yes for an exact solution it will be too slow. But this is computer graphics for entertainment and not safety critical software for medicine or something like that. Which means you can cheat with approximation as much you want as long as the result looks good ;) All iterative solvers will only be dependent on local values, you will need a maximum of a few iterations and they will basically be as fast as a couple of convolutions which is definitely fast enough.
â mathreadler
Aug 25 at 14:53
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f333991%2fhow-to-combine-b%25c3%25a9zier-curves-to-a-surface%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
I am not so sure Bézier curves would be easy to fit. Easier would be some interpolation scheme, like cubic interpolation. I would try an inverse discrete wavelet transform interpreting as low-low-low frequency band. Potentially with applying some regularization. Or you could just build a big equation system where you push function values towards the edges and regularize for first and second order differentials. The last method is so powerful you can fuse the solution it to parametric functions like polynomials if you want to.
â mathreadler
Aug 19 at 8:02