i really love jme3, good work guys! The documentation is great, too. Thanks.
i am tring to develop a kind of strategy game. The player has some units, not many, currently is 10 the maximum. The units have some abilities and stats. They have a field of view, too.
The player should only see enemy units if they are in the field of views of one of his units. The scene in total should be darker in areas where no unit can look at.
I describe my solution and would like to ask you for comments if this is the way to go or if that is the incorrect way to do that.
Spatials are culled with the current camera frustum. The correct approach would be (?): Before rendering, go through the enemy units and test them against the field of views of the friendly units and set cullhint.always to them if they arent in line of sight.
If i want to draw the enemy units in a different kind of style instead of making them invisible if they arent in a field of view i would have to add a shader variable and manipulate the rendering of the unit in the shader.
I looked at the filters (e.g. SSAO and Glow) and came to that solution:
I would have to introduce a new technique (“fogOfWarPass”). Add a Post Processing Filter with a pass with enforcing technique “fogofwar”, render it for each field of view parameters of a friendly unit (i had kind of view frustum in mind) In the shader of the technique i calculate a kind of color falloff (to get it darker) with the normal and the view vector of the viewing friendly unit. Based on the resulting “texture” i add an fullscreenquad and use the rendered texture to darken certain areas.
To do the whole thing i would have to extend the lightning shader with the new parameters and that new technique and set the new materialdefinition to the materials of the envrionment objects and units.
Is that the correct way to to that? Does the “shader injection” solve the problem of copy pasting shaders? Or is there already a kind of shader inheritance and i dont have to copy and paste? ( )
Is there already some kind of shader in JME3 where i can find some ideas for the second thing? The whole reminds me to somwhat “angular lightning”.
Hm, with a shader you should be able to determine the absolute location of a fragment (using the depth) and then just paint fog there instead. Basically the existing post-pro fog should already be most of what you need I guess…