Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am running a iOS project using the isgl3d framework for showing pod files.

I have a stylish car with 0.5 alpha windows, that I wish to render on a camera background, seeking some augmented reality goodness.

The alpha on the windows looks okay, but when I add the object, I notice that it renders the entire object transparently, where the windows are. Including interior of the car.

Like so (in example, keyboard can be seen through the dashboard, seats and so on. should be solid)

bad car is bad

The car interior is a seperate object with alpha 1.0.

I would rather not show a "ghost car" in my project, but I haven't found a way around this.

Have anyone encountered the same issue, and eventually reached a solution ?

share|improve this question
    
Try turning off the alpha write mask when you render the car. –  echeese Apr 18 '12 at 14:18

2 Answers 2

(No experience with 3D programming on iOS, but this should work on regular OpenGL devices.)

I can think of 2 options that might fix this.

Try separating the model in 2 parts, first render the opaque part and then render the transparent part.

Another option might be to disable alpha writing when rendering the object. What I think is happening is that when the window is rendered the alpha value is simply written to the color buffer. When then rendering the color buffer over the camera image the windows are alpha blended with the image behind it, causing ghost cars.

share|improve this answer
up vote 3 down vote accepted

SOLVED: Thanks to Demi. Here is the final code:

// Render opaque objects
        [_scene render:renderer opaque:true];

        // First planar shadow pass (if needed)
        [self renderPlanarShadows:renderer];

        // Render transparent objects
        glColorMask(1, 1, 1, 0);
        if (_zSortingEnabled) {
            [_scene renderZSortedAlphaObjects:renderer viewMatrix:&viewMatrix];

        } else {
            [_scene render:renderer opaque:true];
        }
        glColorMask(1, 1, 1, 1);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.