ryerrabelli / jmonkeyengine

Automatically exported from code.google.com/p/jmonkeyengine
0 stars 0 forks source link

MaterialLoader for ogre material does not support "depth_write off" #408

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Some ogre material may looks like this:

material 02___Default/ALPHA/TEX/yy2.png
{
    technique
    {
        pass
        {
            diffuse 1.000000 1.000000 1.000000
            specular 0.000000 0.000000 0.000000 1.250000
            scene_blend alpha_blend 
            depth_write off
            texture_unit
            {
                texture yy2.png
            }
        }
    }
}

Current material loader just ignored the "depth_write off"

It could be implemented like this:

After:
else if (keyword.equals("lighting")){
            String isOn = split[1];
            if (isOn.equals("on")){
                noLight = false;
            }else if (isOn.equals("off")){
                noLight = true;
            }
        }
Add:
else if (keyword.equals("depth_write")){
            String isOn = split[1];
            if (isOn.equals("on")){
                depthWrite = false;
            }else if (isOn.equals("off")){
                depthWrite = true;
            }
        }
...

in method compileMaterial()

if(!depthWrite)
{
    mat.getAdditionalRenderState().setDepthWrite(depthWrite );
}

It helps to diplay some special organized scene for some effects.~~

Original issue reported on code.google.com by wujiay...@msn.com on 18 Oct 2011 at 6:06

GoogleCodeExporter commented 8 years ago

Original comment by normen667 on 18 Oct 2011 at 4:39

GoogleCodeExporter commented 8 years ago

Original comment by normen667 on 18 Oct 2011 at 4:39

GoogleCodeExporter commented 8 years ago
In 99% of the cases of why depth_write off appears in an Ogre3D material file 
is because transparency is enabled. If depth_write is disabled for a 3D model 
with multiple layers, such as a structure or character model, the result will 
appear very bad as triangles that are supposed to be in the back will appear on 
the front and so on. It is useful however for certain models where the triangle 
order is known to never cause this artifact or when the model itself doesn't 
have many depth layers through which it can be viewed. The chances of this 
being applied to a 3D model is higher, therefore applying this change will do 
more harm than good. Marked as "WontFix". 
NOTE: In the future we may add a specialized "vegetation" rendering mode that 
will render the models in two passes, which might fix some of the issues that 
people like the OP are having with transparent but not translucent models

Original comment by ShadowIs...@gmail.com on 18 Oct 2011 at 6:21

GoogleCodeExporter commented 8 years ago
Hi, thanks for the comment.

Diable depth write is not widely used. But if a material declares to disable 
depth write, I guess the artist do know what he need. The model must have been 
well structed. While the model does not display the same as in ogre, it will be 
programmers' work to find why we get the different pictures. Then the 
programmer will check these code just like what i did, fix it in his own engine 
code or add a hack code outside the engine code. It seems to be a little dirty.

Original comment by wujiay...@msn.com on 20 Oct 2011 at 7:41

GoogleCodeExporter commented 8 years ago
:(
I did some homework.
It is not really a good behavior that we can disable depth write in j3m 
material but we can not do the same thing in ogre material. Is that because 
ogre is not a product of jme?

Original comment by wujiay...@msn.com on 21 Oct 2011 at 10:04