• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By Jiraya
      For a 2D game, does using a float2 for position increases performance in any way?
      I know that in the end the vertex shader will have to return a float4 anyway, but does using a float2 decreases the amount of data that will have to be sent from the CPU to the GPU?
       
    • By ThunderTwonk
      Hello everyone, I am working on a game idea and since I am still in the process of learning C# and the features available in unity I was hoping some of you might be able to offer me a little insight on things in general for getting started.
      I guess the basic components of what I'm wanting to create would be a Multi-levels management/city builder/rpg.
      The goal is to provide a framework for players to interact with, build in and affect the world both from a 3rd person action RPG as well as a zoomed out 4x style view (This would be something unlocked through gameplay)
       
      As for my questions go I was wondering if anyone had resources that could help me learn.  I've been on youtube as well as enrolled in an online course for basic unity and C# and will continue those but if anyone has any words of advice, a place that has good information and tutorials etc.
       
      Thanks for your time.
    • By INFRA
      SCAN. DRILL. SURVIVE.   ISOLATED Release in May 1st 2018   https://store.steampowered.com/app/805950/Isolated/   A game by Jérémie Bertrand Music & Sound Design by Pierrick Querolle *** Our solar system has been invaded by strangers. For the purpose of a possible negotiation, a team of astronauts is sent to the moon. Alas, they are shot before even arriving on the scene. Only one astronaut survives the crash and his only goal will be to go home...   GAMEPLAY   Shoot enemy ships to avoid being invaded. Be precise in your movements, because it's better to lose a bit of life at the top than to lose it all at the bottom. Take out your drill to destroy the stones in your path. Validate your identity to cross the different laboratories. Reach the flag before losing your three lives.   And all that... at the same time! Will you be able to go home? If the answer is yes, how long will it take?
    • By Captain Jack
      Hi,
      Two questions: I am trying to rotate chroma in YUV colour space by separating each of the components and applying the following formula.
      int Ut = ((U-128) * cos(hue[H]) + (V-128) * sin(hue[H])) + 128; int Vt = ((V-128) * cos(hue[H]) - (U-128) * sin(hue[H])) + 128; ...where hue[H] is an array of rotation angles between 0.0 and 360.0.
      This seems to work OK but is dog slow. Is there a way to speed this up by converting to integer only calculation and doing away with cosine and sinus? 
      Second, when doing conversion between YUV and RGB, it seems that luma is also affected after rotation. To demonstrate what I mean, I am randomly rotating each line's chroma. The process is:
      Convert from RGB to YUV > rotate chroma > convert to RGB.

      Top left is the original image, the two images on the right are U and V and the bottom left is the luma. As you can see, it seems to have some artefacts from rotation. Is there a way to avoid this?
      Thanks
      CJ
  • Advertisement
  • Advertisement

Recommended Posts

Hello guys! Totally new here, as well as to graphics programming in general.

 

I'm making a 2D fighting game engine using XNA/MonoGame, and oddly enough what's tripping me up is how I can have the user define their lifebars. Obviously the simplest (old-school) method would be to just use a bounding rect to cut off the display region of the current sprite/animation to only the "remaining life" region. Done.

 

But what if they want to define some other non-rectangular shape for the end of the lifebar, such as a rhombus, or pill shape? So I figure, why not have them make a mask sprite to define what the end of the lifebar should look like? That way they can have whatever end shape they want at any point in the lifebar, whether it's a static sprite or animation. It will also provide another useful tool familiar to designers that they can also use anywhere else in the engine.

 

Basically, I want the user to be able to insert a sprite like this:

Photoshop_2017-07-01_13-57-52.png.a844ed385663f728b6b519f5366df053.png

 

And a sprite like this:

Photoshop_2017-07-01_13-58-30.png.d57b03398b26f2867a6b4c5070837f57.png

 

And end up with this at the end of the lifebar (after aligning the mask with the end of the lifebar):

Photoshop_2017-07-01_13-59-08.png.7e02f1563356e143e45595eee6b12a72.png

 

The algorithm itself is simple. I just need it to take the sprite and multiply it by the color (or color component, to simplify things) in the overlapping mask sprite.

 

But the problem is this: the mask texture and the lifebar texture may be different dimensions. In what I've worked with in HLSL so far, the texture indices are represented from 0.0F to 1.0F in the X or Y direction. So in my head, that mask sprite is going to be treated the same size as the lifebar texture, which means it would create a totally different image as the life decreases!

 

I'm using HLSL, but I'm unsure how to approach this problem. Is there any way to check image dimensions so I can tell it to use the mask texture as-is, and not clip anything outside of the mask texture?

Edited by Jesuszilla
DX11 tag since HLSL is for DirectX

Share this post


Link to post
Share on other sites
Advertisement

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