• Advertisement
Sign in to follow this  

Unity gui gradient scaling?

This topic is 3475 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In a continuation from this thread i would like to ask a follow up question. Basically i want to have a Y axis gradient but in the other thread nife87 said to keep the borders 1xA were 'A' is the size of the corners. If i do that i would be able to have a gradient so how exactly are gradients done in GUI development? Thanks

Share this post


Link to post
Share on other sites
Advertisement
For simple linear gradients you can use per vertex colors. The gpu will do the linear interpolation and create the gradient.

Share this post


Link to post
Share on other sites
But for this GUI i'm using images so how would i do it using them?

Share this post


Link to post
Share on other sites
Quote:
Original post by carlj133
But for this GUI i'm using images so how would i do it using them?


You cannot have Y-axis gradient on the vertical borders using the previously explained method. Normally such gradients will be made with simple colors like Kambiz suggested or perhaps by actually making/creating the images run-time (this will then be needed every time the window is scaled) to avoid scaling static/premade images. The latter solution is clearly the most flexible, since you can do much more than just simple linear gradients. But should you choose the latter solution, you could also go with a shader-based approach (may be too much for your needs), where some parts of the GUI are still stored as static images (only parts that cannot be calculated via simple formulas), and where some parts (preferably most parts) are created dynamically in shaders.

Share this post


Link to post
Share on other sites
Quote:
Original post by nife87
Quote:
Original post by carlj133
But for this GUI i'm using images so how would i do it using them?


You cannot have Y-axis gradient on the vertical borders using the previously explained method. Normally such gradients will be made with simple colors like Kambiz suggested or perhaps by actually making/creating the images run-time (this will then be needed every time the window is scaled) to avoid scaling static/premade images. The latter solution is clearly the most flexible, since you can do much more than just simple linear gradients. But should you choose the latter solution, you could also go with a shader-based approach (may be too much for your needs), where some parts of the GUI are still stored as static images (only parts that cannot be calculated via simple formulas), and where some parts (preferably most parts) are created dynamically in shaders.

It's not on the vertical borders. It's the left-hand side border.

Share this post


Link to post
Share on other sites
Quote:
Original post by carlj133
But for this GUI i'm using images so how would i do it using them?


Use gray scale images and multiply the colors with the gradients. This doesn't even require shades. (If you are using OpenGL look how the boxes in NeHe lesson 12 are colored, it is really simply: just set the vertex colors and render just like before... )
EDIT:
To make it clear, unlike lesson 12 you have to give each vertex a different color:


[Edited by - Kambiz on August 16, 2008 6:43:22 PM]

Share this post


Link to post
Share on other sites
But what do you do if you want more control over the gradient. Where the second color
starts blending in and where it's the only color. I don't you can get this using this method.

Share this post


Link to post
Share on other sites
With a shader it is definitely possible, but instead of colors, you would have to assign texture coordinates which get converted to a color (via a gradient) in the shader.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
  • Advertisement
  • Popular Tags

  • Advertisement
  • Popular Now

  • Similar Content

    • By Yosef BenSadon
      Hi , I was considering this start up http://adshir.com/, for investment and i would like a little bit of feedback on what the developers community think about the technology.
      So far what they have is a demo that runs in real time on a Tablet at over 60FPS, it runs locally on the  integrated GPU of the i7 . They have a 20 000 triangles  dinosaur that looks impressive,  better than anything i saw on a mobile device, with reflections and shadows looking very close to what they would look in the real world. They achieved this thanks to a  new algorithm of a rendering technique called Path tracing/Ray tracing, that  is very demanding and so far it is done mostly for static images.
      From what i checked around there is no real option for real time ray tracing (60 FPS on consumer devices). There was imagination technologies that were supposed to release a chip that supports real time ray tracing, but i did not found they had a product in the market or even if the technology is finished as their last demo  i found was with a PC.  The other one is OTOY with their brigade engine that is still not released and if i understand well is more a cloud solution than in hardware solution .
      Would there  be a sizable  interest in the developers community in having such a product as a plug-in for existing game engines?  How important  is Ray tracing to the  future of high end real time graphics?
    • By bryandalo
      Good day,

      I just wanted to share our casual game that is available for android.

      Description: Fight your way from the ravenous plant monster for survival through flips. The rules are simple, drag and release your phone screen. Improve your skills and show it to your friends with the games quirky ranks. Select an array of characters using the orb you acquire throughout the game.

      Download: https://play.google.com/store/apps/details?id=com.HellmodeGames.FlipEscape&hl=en
       
      Trailer: 
       
    • By Manuel Berger
      Hello fellow devs!
      Once again I started working on an 2D adventure game and right now I'm doing the character-movement/animation. I'm not a big math guy and I was happy about my solution, but soon I realized that it's flawed.
      My player has 5 walking-animations, mirrored for the left side: up, upright, right, downright, down. With the atan2 function I get the angle between player and destination. To get an index from 0 to 4, I divide PI by 5 and see how many times it goes into the player-destination angle.

      In Pseudo-Code:
      angle = atan2(destination.x - player.x, destination.y - player.y) //swapped y and x to get mirrored angle around the y axis
      index = (int) (angle / (PI / 5));
      PlayAnimation(index); //0 = up, 1 = up_right, 2 = right, 3 = down_right, 4 = down

      Besides the fact that when angle is equal to PI it produces an index of 5, this works like a charm. Or at least I thought so at first. When I tested it, I realized that the up and down animation is playing more often than the others, which is pretty logical, since they have double the angle.

      What I'm trying to achieve is something like this, but with equal angles, so that up and down has the same range as all other directions.

      I can't get my head around it. Any suggestions? Is the whole approach doomed?

      Thank you in advance for any input!
       
    • By khawk
      Watch the latest from Unity.
       
    • By GytisDev
      Hello,
      without going into any details I am looking for any articles or blogs or advice about city building and RTS games in general. I tried to search for these on my own, but would like to see your input also. I want to make a very simple version of a game like Banished or Kingdoms and Castles,  where I would be able to place like two types of buildings, make farms and cut trees for resources while controlling a single worker. I have some problem understanding how these games works in the back-end: how various data can be stored about the map and objects, how grids works, implementing work system (like a little cube (human) walks to a tree and cuts it) and so on. I am also pretty confident in my programming capabilities for such a game. Sorry if I make any mistakes, English is not my native language.
      Thank you in advance.
  • Advertisement