behind effect

Posted By: sivan

behind effect - 11/03/14 11:38

hi,

I want to implement in future a behind-effect shader, a usual thing in RTS games displaying units behind trees/buildings/obstacles as a coloured outline or a filled shape like this:



any idea how does it work?
I want to avoid using a new view, maybe a 2nd pass is enough?

thanks.
Posted By: MasterQ32

Re: behind effect - 11/03/14 12:17

Set ZNEAR or add the corresponding render states for ZFunc and so on..
Posted By: sivan

Re: behind effect - 11/03/14 13:47

ööö... now I'm not sure exactly how but at least a good starting point laugh
Posted By: Kartoffel

Re: behind effect - 11/03/14 13:54

znear is a flag. You just have to use set();
Posted By: sivan

Re: behind effect - 11/03/14 14:48

I know that. but don't know how to utilize it to display the covered parts of an animated model with a colour, when it is partially covered by another model.
Posted By: Kartoffel

Re: behind effect - 11/03/14 16:56

I'd go for some custom pixel shader with depth testing...

Maybe there's some other, clever way using ZFunc and rendering the model several times.

EDIT: yeah, writing the model with a first pass (blue-see-through-wall-colored, no depthtesting, no alphawrite) and then rendering the model in a second pass as usual (with depthtesting and alphawrite)

maybe it's even easier, I don't know what kind of stuff zFunc supports since I never use it...
Posted By: MasterQ32

Re: behind effect - 11/03/14 19:26

i think kartoffels idea is the right way i don't think it will work in one pass
Posted By: Kartoffel

Re: behind effect - 11/03/14 21:57

maybe it can be done a little bit more efficient (although still with two passes)
I'll give it a try but not today anymore
Posted By: sivan

Re: behind effect - 11/04/14 08:12

thanks, what I really needed was the concept. 2 passes migth be okay, probably I'll use it only for the 1st 1-2 lods to lower performance cost caused by the high unit model quantity.
Posted By: sivan

Re: behind effect - 11/04/14 10:47

by ZEnable I can do this (ZFunc does not really help and ZNEAR also seems to be not useful):



unfortunately unit-to-unit coverage has a bad look I can't resolve currently...
Posted By: MasterQ32

Re: behind effect - 11/04/14 12:17

i think the stencil buffer could help here but i have no idea how it works....
Posted By: sivan

Re: behind effect - 11/04/14 12:26

I use shadow_stencil -1, so it is disabled in theory... I try to take a look in the source of 0.A.D., but it is opengl...
© 2024 lite-C Forums