Jump to content
  • Advertisement
RoyalWing

Algorithm Fair perspective top down camera problem

Recommended Posts

Posted (edited)

Greetings. Its my first post here so excuse me if i'm doing something wrong.

Our team is working on top down shooter with perspective camera and we are trying to find a way to make fair camera that correctly limited for any aspect ratio.
Camera is moving using basis point and positioned in relative space of this basis.
Common requirements :

  • Camera movement limited to avoid players with different aspect ratios observation areas that are not available to be observed by other players.
  • Camera limited by radius around single point in world space (player).
  • Limitation should be soft. It means that camera should not hard hit limitation edge and just slowly drop speed upon approaching.
  • Camera should be able to move in Z dimension.
  • Camera movement speed should be equal in screen space.
  • Camera limits should be equal in any directions in world space (diagonal is optional).
  • Camera should correctly react on changing its angle.
  • Camera movement should be made only using basis point position, rotation and distance between camera and basis point.

 

preview.png

Video with a try of implementation one of our ideas. We tried to compensate by mathematical curves for each aspect of influences (aspect ration, interpolation power, camera height, etc.).
It happened that there were double dependencies that conflict with each other. It required two aspects at a time to depend on and its supposed to be something like graph or blendspace (UE4 threm) ti make it possible to work. It may cost to much time to implement.

 

Looking for ideas of implementation. Thanks for attention.

Edited by RoyalWing

Share this post


Link to post
Share on other sites
Advertisement

This could be done by defining your own fixed aspect ratio say 16:9 or 4:3 and shrink/stretch the image to the screen size, youll get something like cinematic view there where you will have black rects at top and bottom of the screen if screen ratio aint the same you have defined (could be at left and right too)

 

 

Heres a code for stretching

vec2 return_texdim(TGLTexture * tx)
{

int screen_width = SCREEN_WIDTH;  
int screen_height = SCREEN_HEIGHT; 
 
// This is your target virtual resolution for the game, the size you built your game to
int virtual_width=tx->px_width;
int virtual_height=tx->px_height;
 
float targetAspectRatio = float(virtual_width)/float(virtual_height);
 
// figure out the largest area that fits in this resolution at the desired aspect ratio
int width = screen_width;
int height = (int)(float(width) / targetAspectRatio + 0.5 );
 
if (height > screen_height )
{
   //It doesn't fit our height, we must switch to pillarbox then
    height = screen_height;
    width = (int)(float(height) * targetAspectRatio + 0.5f);
}
 


return vec2(float(width)/float(SCREEN_WIDTH), float(height)/float(SCREEN_HEIGHT));

}

 

Share this post


Link to post
Share on other sites
9 minutes ago, _WeirdCat_ said:

This could be done by defining your own fixed aspect ratio say 16:9 or 4:3 and shrink/stretch the image to the screen size, youll get something like cinematic view there where you will have black rects at top and bottom of the screen if screen ratio aint the same you have defined (could be at left and right too)

 

 

Heres a code for stretching


vec2 return_texdim(TGLTexture * tx)
{

int screen_width = SCREEN_WIDTH;  
int screen_height = SCREEN_HEIGHT; 
 
// This is your target virtual resolution for the game, the size you built your game to
int virtual_width=tx->px_width;
int virtual_height=tx->px_height;
 
float targetAspectRatio = float(virtual_width)/float(virtual_height);
 
// figure out the largest area that fits in this resolution at the desired aspect ratio
int width = screen_width;
int height = (int)(float(width) / targetAspectRatio + 0.5 );
 
if (height > screen_height )
{
   //It doesn't fit our height, we must switch to pillarbox then
    height = screen_height;
    width = (int)(float(height) * targetAspectRatio + 0.5f);
}
 


return vec2(float(width)/float(SCREEN_WIDTH), float(height)/float(SCREEN_HEIGHT));

}

 

I think image distortion could give negative shade on a player exper8ence. Dont you think?

Share this post


Link to post
Share on other sites

Same view whatever the screen size sounds very tricky to me. Suppose I have a 3:4 screen. You define an area. Then I rotate my screen by 90 degrees, and I have 4:3. What must change?

The only solution I can imagine is that you take the minimum length in both width and height. My screen view would end up rectangular (ie 3:3), with black side borders if you also forbid scaling different amounts in width and height.

 

Maybe you should query the display of all users, and compute the best solution in some way.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!