PDA

View Full Version : Stencil buffer.


12171217
07-10-2010, 10:35 PM
Why can't we touch the stencil buffer in GS2? :(

I wanted to do reflection effects for players in water, among many other things..

Admins
07-11-2010, 01:39 AM
This can probably be interesting but could you explain a little bit more what you want to do and how?

12171217
07-11-2010, 04:12 AM
You would enable writing to the stencil buffer by doing a generic function, like
graphicsEnable(STENCIL_BUFFER);

then, you would, in most cases, clear the stencil buffer before you start using it.
graphicsClear(STENCIL_BUFFER);

Following, since you're in stencil mode, any showimgs, anything that would normally be drawn to the draw buffer is now drawn to the stencil buffer. You set an operation using
setStencilOp(STENCILOP);
and could choose from the following operations:

STENCILOP_KEEP
STENCILOP_ZERO
STENCILOP_REPLACE
STENCILOP_INVERT
STENCILOP_INCR
STENCILOP_DECR

Finally, after creating a proper stencil buffer, you could then test against it when drawing images:
stencilTestFunc(STENCILTEST);

STENCILTEST_NEVER
STENCILTEST_LESS
STENCILTEST_LESSEQUAL
STENCILTEST_EQUAL
STENCILTEST_GREATER
STENCILTEST_GREATEREQUAL
STENCILTEST_NOTEQUAL
STENCILTEST_ALWAYS

Setting a reference value could just be something like
stencilSetReference(int);

Could be used for tons of stuff.. Parallax scrolling backgrounds, reflections of sky images in water, reflections of players in water.. Tons of very interesting uses if it's put to good use.

If you've ever used the stencil buffer in an OpenGL application, you'd be familiar with how to use it and you'd see a bunch of potentional, too :D

12171217
07-13-2010, 09:52 PM
Not to mention this could be used to clip images against bounding boxes, for minigames and such.. I really ****ing need that, especially since clipping showpolys is slow compared to taking advantage of the stencil buffer.

12171217
07-26-2010, 09:21 AM
Bump. :D

Dnegel
08-03-2010, 06:59 PM
This sounds interesting, should do something with it.

Crono
08-07-2010, 03:04 AM
u cud use it to fulfil my dream~

DustyPorViva
08-07-2010, 05:25 AM
u cud use it to fulfil my dream~
I've been wanting reflections for so long :(

Graal needs way more special effects. It can add so much atmosphere!

Fulg0reSama
08-07-2010, 05:27 AM
u cud use it to fulfil my dream~

I've always wanted a lake and a fence.

12171217
08-07-2010, 06:18 AM
Stencil buffer plz <3

Also, render-to-texture support while we're at it! If I'm not mistaken in the technique you use for certain GUIControls, it's nothing more than adapting your GUIDrawingPanel's.

MrOmega
08-13-2010, 01:50 PM
I guessing this would be more efficient than having an extra image/NPC, rotating it, and lowering the alpha?

Crow
08-13-2010, 01:50 PM
I guessing this would be more efficient than having an extra image/NPC, rotating it, and lowering the alpha?

Hell yes!

smirt362
08-13-2010, 02:35 PM
Parallax scrolling backgrounds

Hell yes

MrOmega
08-13-2010, 04:16 PM
So graal will go from basically Zelda 3 with upgrades to to pretty much the four sword adventures? Effects wise. I vote yes.

adam
08-14-2010, 02:43 AM
Would be nice if graal could compete with other 1-man team indie games someday.

Admins
08-14-2010, 08:41 PM
To be honest I'm not sure if such things can be added anytime soon. We use it for some of our iPhone games but it's not that easy to expose to script. There are however other things in the works which can also improve Graal graphically in the future.

Crow
08-14-2010, 11:14 PM
To be honest I'm not sure if such things can be added anytime soon. We use it for some of our iPhone games but it's not that easy to expose to script. There are however other things in the works which can also improve Graal graphically in the future.

Do it! An ETA on v6 wouldn't be bad, either.

12171217
08-16-2010, 12:33 AM
To be honest I'm not sure if such things can be added anytime soon. We use it for some of our iPhone games but it's not that easy to expose to script. There are however other things in the works which can also improve Graal graphically in the future.

I've seen the stencil buffer bound to Lua functions and a clientside interpreted language added to Quake, but if you don't feel capable..

Another thing I'd like to see is showimg, minus the layer sorting, depth sorting, and all that. Just draw it directly to the frame buffer as soon as it's called, and forget about it forever once the frame ends; just like blitting an image in SDL or whatever other graphics front. It'd make certain scripts easier to write where you have to manually draw an entire world for, say, an isometric or raycasting script, draw back-to-front, or front-to-back to get certain things looking right, and if I'm not mistaken it'd probably be significantly faster, since the client wouldn't be creating and destroying, sorting depth through tons of image objects.

smirt362
08-16-2010, 02:05 AM
To be honest I'm not sure if such things can be added anytime soon. We use it for some of our iPhone games but it's not that easy to expose to script. There are however other things in the works which can also improve Graal graphically in the future.

Please try :cry:

MrOmega
08-16-2010, 03:44 AM
To be honest I'm not sure if such things can be added anytime soon. We use it for some of our iPhone games but it's not that easy to expose to script. There are however other things in the works which can also improve Graal graphically in the future.

What other things?

gravator
08-16-2010, 04:58 AM
Stefan, you make it sound as if the current developers are stuck using the same tools as during 2001 and are just waiting for V6 release, there has to have been some new goodies added to make a really fun and beautiful server, Konidias managed to get some very nice graphics in bomy island so i'm very certain similar quality should be available now instead of the much older tilesets that are still in use on Era, UN and Zodiac or many of the hosted and under construction servers.

Combining Koni level work with Gonstruct would make one impressive and very professional looking server.

DustyPorViva
08-16-2010, 05:19 AM
Stefan, you make it sound as if the current developers are stuck using the same tools as during 2001 and are just waiting for V6 release, there has to have been some new goodies added to make a really fun and beautiful server, Konidias managed to get some very nice graphics in bomy island so i'm very certain similar quality should be available now instead of the much older tilesets that are still in use on Era, UN and Zodiac or many of the hosted and under construction servers.

Combining Koni level work with Gonstruct would make one impressive and very professional looking server.
But there are limitations... Sure, we've had some advancements in effects like particles and scaling of images and such, but that's about it. There are some more dramatic effects that would make the game look way better... like already mentioned, reflections in the water, screen distortion that you often see in RPGs(think the waves from heat, making the screen slowly flow with waves), the ability to subtract from an image(for lamps like in Minish Cap), the ability to desaturate/color the screen for things like an ol' time effect. All these things would give creative developers an edge to make something that looks that much better.

And Koni's BI didn't really push Graal to its limits.

MrOmega
08-16-2010, 03:23 PM
But there are limitations... Sure, we've had some advancements in effects like particles and scaling of images and such, but that's about it. There are some more dramatic effects that would make the game look way better... like already mentioned, reflections in the water, screen distortion that you often see in RPGs(think the waves from heat, making the screen slowly flow with waves), the ability to subtract from an image(for lamps like in Minish Cap), the ability to desaturate/color the screen for things like an ol' time effect. All these things would give creative developers an edge to make something that looks that much better.

And Koni's BI didn't really push Graal to its limits.

just an oddball idea but couldn't you just set the RGB value of all objects to sepia tone levels for ol' time effect?

12171217
08-16-2010, 04:16 PM
Doesn't Graal have a subtractive blending mode?

Tigairius
08-16-2010, 09:39 PM
But there are limitations... Sure, we've had some advancements in effects like particles and scaling of images and such, but that's about it. There are some more dramatic effects that would make the game look way better... like already mentioned, reflections in the water, screen distortion that you often see in RPGs(think the waves from heat, making the screen slowly flow with waves), the ability to subtract from an image(for lamps like in Minish Cap), the ability to desaturate/color the screen for things like an ol' time effect. All these things would give creative developers an edge to make something that looks that much better.

And Koni's BI didn't really push Graal to its limits.

With this said, I'd like to add: oh my god I wish you could have images subtract from seteffects and other images.

DustyPorViva
08-16-2010, 09:42 PM
With this said, I'd like to add: oh my god I wish you could have images subtract from seteffects and other images.
Stefan actually replied to one of my topics about it and said it's require a new buffer of the sort... and that was it. He didn't sound too enthusiastic about it.

Tigairius
08-16-2010, 09:50 PM
Stefan actually replied to one of my topics about it and said it's require a new buffer of the sort... and that was it. He didn't sound too enthusiastic about it.

That's rather unfortunate. I could have used these effects many times. I know I've brought it up with him personally before too.

Crow
08-16-2010, 10:31 PM
Doesn't Graal have a subtractive blending mode?

Mode 2 is subtractive, yes.