[Closed] fx shaders that uses depthstencil…clearing buffer?
Hello!
I dont know a lot about hardware shaders but I need one for a character rig Im building, so Ive been trying to make one.
I needed one that draws certain objects/materials on top of others, even if theyre inside them. and I pretty much got it working, I think, although Im sure its hacky and ugly as hell for people who know how its supposed to be done.
anyways, it seems to be working by using a DepthStencil being fed a reference value through an integer parameter to use as “sort order”. (at least it works if I turn off viewport gradual improvement and degrading) there are some issues like randomly some bits flicker through etc. but something seems to be going in the right direction and its already at least usable.
BUT it doesnt seem like the stencil buffer (?) is cleared on every redraw. while interacting in the viewport it seems like its using some old buffer data so that things are increasingly masked out where an object WAS. and then on some interactions (kind of hard to explain but for instance on very short moves, though not single clicks…) it “resets” and looks fine again. so…Im out of my depth. any info on the following would be much appreciated:
- am I supposed to clear this buffer myself in the shader? how do I do that? in another pass? (yeah I dont know much about shaders…did I mention it?)
1b) according to opengl tutorials and stuff there are commands to clear it to a certain value…but its not like I can do that through cpp. does max do the clearing? are the values 0 by default like they seem to be?
-
is max using the stencil for other stuff? is it a bad idea to mess around with it? (but then, it seems to be working a little too well for that to be true)
-
what exactly is going on with the viewport options? what does the gradual improvement and the other stuff actually do and how does it relate to custom shaders? Id rather not everyone who uses the rig has to change their settings if it can be helped. (changing the shading style to “shaded” I can live with)
Apologize if this is frequently covered. its kind of hard to google for some reason. especially specifically shaders for max. and the only shader that comes with max that actually seems to work (that shows its parameters and in the viewport) is the one called StandardFX11… so they dont really help me for reference. (whats up with that)
In fact Im not even sure what language this is. =D cgfx??
any help welcome.