luxeengine / alpha

alpha - deprecated 2015~2016. unrelated to the new engine! view the new engine here - https://luxeengine.com/
MIT License
565 stars 74 forks source link

Phoenix; Camera settings overwrite prerender changes #369

Closed ntrf closed 8 years ago

ntrf commented 8 years ago

In function Batcher::draw prerender callback is executed before update_view, which will eventually call Camera::process and overwrite the CULL_FACE setting done in prerender callback.

As a result this code has no effect:

        effectsBatcher = Luxe.renderer.create_batcher({
            name: "Particles (Additive blend, dual-sided)",
            camera: Luxe.camera.view,
            layer: 3
        });
        effectsBatcher.on(prerender, function(_) {
            Luxe.renderer.state.disable(GL.CULL_FACE); //<<< this state change will not hold
            Luxe.renderer.blend_mode(src_alpha, one);
        });
        effectsBatcher.on(postrender, function(_) {
            Luxe.renderer.state.enable(GL.CULL_FACE);
            Luxe.renderer.blend_mode();
        });

I had to add Luxe.camera.view.cull_backfaces = false; and reverse in order to make it work.

ruby0x1 commented 8 years ago

You wouldn't typically call Luxe.renderer.state directly like that (since the camera has the option), the correct usage is to set the camera options like you mentioned. What do you mean reverse order?

ntrf commented 8 years ago

Ok. It wasn't obvious to me that RenderState should not be accessed like that becase it has properties, which can not be changed otherwise (like depth order).

I'm using one camera to render 3d models (depth test on, no back faces, z-write), particles (depth tested, no z-write, front and back faces) and attached ui elements (depth test and z-write off). So i have multiple batches refering to a single camera. For particle batch i have to set cull_backfaces = true in prerender and cull_backfaces = false in postrender. It feels like camera setup should not be changed from one batcher to another.

ruby0x1 commented 8 years ago

Yea the renderer is (as mentioned in many dev logs) changing to embers, while phoenix was designed pre-luxe, embers fits more of the approach luxe will take going to 1.0.