Author Topic: Paid job offer: unity textbox replacement. (Retracted for now)  (Read 29116 times)

Offline Draco18s

  • Resident Velociraptor
  • Core Member Mark V
  • *****
  • Posts: 4,251
Re: Paid job offer: unity textbox replacement. (Retracted for now)
« Reply #15 on: August 27, 2014, 11:26:30 am »
The layers are just offsets on one axis, but yeah.  Needed a lot of them!  :o

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Paid job offer: unity textbox replacement. (Retracted for now)
« Reply #16 on: August 27, 2014, 11:38:17 am »
Pay no attention to the renderer behind the curtain.
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline Draco18s

  • Resident Velociraptor
  • Core Member Mark V
  • *****
  • Posts: 4,251
Re: Paid job offer: unity textbox replacement. (Retracted for now)
« Reply #17 on: August 27, 2014, 12:10:38 pm »
Pay no attention to the renderer behind the curtain far clip plane.

FTFY. :P

Offline orzelek

  • Hero Member Mark III
  • *****
  • Posts: 1,096
Re: Paid job offer: unity textbox replacement. (Retracted for now)
« Reply #18 on: August 27, 2014, 07:16:45 pm »
If stencils are available it seems that they might be way to go.
I'm only familiar with OpenGL have no idea about D3D.
Stencils allow for a lot of tricky stuff - one of application I seen is proper rendering of multi-polygonal anti-aliased lines ;)

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
Re: Paid job offer: unity textbox replacement. (Retracted for now)
« Reply #19 on: August 28, 2014, 08:48:21 am »
Huh!

http://docs.unity3d.com/Manual/SL-Stencil.html

That actually is dead simple and pretty similar to what I have done in the past with the zbuffer.

I... actually could probably do this, based on that.  Our grid views and a number of other things would also benefit from that.  I'm not going to look into it immediately, but this will probably be a side project of mine at some point in the future, because it's definitely interesting.

Cheers!
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
Re: Paid job offer: unity textbox replacement. (Retracted for now)
« Reply #20 on: August 28, 2014, 10:39:05 am »
For future reference, the algorithm is this:

1. Create a shader that draws no real pixels, but instead writes all non-transparent pixels to the stencil buffer with an int value between 1 and 255.  That int value is passed in as a parameter to the shader, so the texture that is passed in along with that int is just used to determine where there are non-transparent pixels.  This would let you create non-rectangular stencils.  If you just wanted rectangles, you could do a version that doesn't have to pass a texture along the GPU pipeline.

2. Create another shader that is just like the normal diffuse shader -- the most basic kind available that just renders a texture in true color with an optional diffuse applied to it.  However, this one uses Equal and an int passed in.  So whenever this new shader is used, it will only render pixels that actually match a place in the stencil buffer

3. Any time you want a clipping area, render a texture using the stencil shader to the area that you want to be the "you can only draw here" area for a future draw call.  Give this a unique number (for this render pass) ranging from 1 to 255.

4. Then when you want to draw the thing(s) to be clipped into that area, use the shader from #2 to do it, and pass in that same integer you used in #3.  They will be magically clipped to that area, but nothing else will.


Using that approach, you could have up to 256 clipped areas onscreen at once for textboxes, scrolling areas, whatever.  It would be quite light on the GPU, too.

Pretty slick!
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline Draco18s

  • Resident Velociraptor
  • Core Member Mark V
  • *****
  • Posts: 4,251
Re: Paid job offer: unity textbox replacement. (Retracted for now)
« Reply #21 on: August 28, 2014, 10:41:55 am »
Snazzy.

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
Re: Paid job offer: unity textbox replacement. (Retracted for now)
« Reply #22 on: August 28, 2014, 10:51:45 am »
Just figured I would share; it's probably cheaper in CPU/GPU than doing things with multiple cameras or occlusion layers, etc.

EDIT: And my "pretty slick" comment was not aimed at myself, incidentally. ;)  I was referring to the people who thought up the stencil buffer, because this is clearly the sort of application they had in mind for it, and it's very useful.  The fact that they made the solution this easy and obvious (for anyone who bothers to look into it more than I previously did) is a really nice thing that I appreciate.
« Last Edit: August 28, 2014, 10:54:06 am by x4000 »
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline Draco18s

  • Resident Velociraptor
  • Core Member Mark V
  • *****
  • Posts: 4,251
Re: Paid job offer: unity textbox replacement. (Retracted for now)
« Reply #23 on: August 28, 2014, 10:53:24 am »
Probably.  It would take me a while to turn the above instructions into a usable thing though.  I only half-understood it.

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
Re: Paid job offer: unity textbox replacement. (Retracted for now)
« Reply #24 on: August 28, 2014, 11:02:38 am »
You know, I just realized when I went to look for the ZWrite examples from Valley 2 that I wound up not using that approach in Valley 2 or Shattered Haven after all.  I have that code back in older repository versions somewhere, but it was not something that supported gradients (which matters in lighting, but not clipping).  I shifted to using RenderTextures that I wrote all black to, then did additive blending of all light sources to it, with the RGB also going into the alpha channel.  Then simply treated that as a texture and drew it on the screen.  That way everything was black except whatever had been turned transparent.  It's really efficient and allows for tons of gradients of any kind you like, and moving light sources that blend together.

So for lights, that's what I wound up doing.  But if you look back in some Valley 1 videos that were in early alpha, you can see some really nutty-looking versions where I used the Zbuffer for lighting.  Some of those things look SUPER odd, haha.  But it would totally work for a GUI.
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!