Color of 3ds meshes

The place to discuss creating, porting and modifying Celestia's source code.
Topic author
bruckner
Posts: 79
Joined: 30.01.2002
With us: 22 years 9 months
Location: Villaviciosa de Od?n, Madrid, Spain

Color of 3ds meshes

Post #1by bruckner » 24.02.2002, 20:21

This is a bug I reported already to Chris, and sent him screenshots of its effects, but I have discovered more details that might be helpful.

The problem appeared when viewing in close range an object with a 3ds mesh: its color seems to fluctuate sharply between different tints of blue, red and yellow as the viewing point moves (even very slightly) with respect to the object. The effect is very noticeable in Amalthea and several asteroids.

What I have discovered is that, when the object is partially visible (because it lies in part beyond the limits of the program's window) the color looks right. This web page shows the effect in more detail: http://bruckner.homelinux.net/celestia_bugs.html

There you can find details about my system, also. I hope this helps to pin this issue down...

Best regards

Bruckner

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Post #2by chris » 25.02.2002, 00:58

I looked at this bug and I *think* that what might be happening is that the colors from rendering the stars are 'leaking' A good way to see if this is what's actually happening would be to modify the colors returned by the StellarClass::getApparentColor method in stellarclass.cpp. Set all the star colors to something easy to spot like Color(1, 0, 1) (magenta) and see if that changes the tint of the 3ds mesh.

--Chris

Topic author
bruckner
Posts: 79
Joined: 30.01.2002
With us: 22 years 9 months
Location: Villaviciosa de Od?n, Madrid, Spain

You've got it right

Post #3by bruckner » 25.02.2002, 06:53

I recompiled with your suggested change, and that was the problem. Amalthea appeared magenta, except when Jupiter was exactly behind (its color varied again, but now in the range of Jupiter's clouds colors). When viewed near the border of the screen, the correct color for Amalthea (red) was rendered.

If I can do anymore to help, don't hesitate to tell me. But remember I'm a Java guy :?

Best regards.

Bruckner

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Post #4by chris » 25.02.2002, 18:38

I can't reproduce this problem, but I may have found a fix. Look for these lines of code:

Code: Select all

starTex->bind();
starDB.findVisibleStars(starRenderer,
                        (Point3f) observer.getPosition(),
                        observer.getOrientation(),
                        degToRad(fov),
                        (float) windowWidth / (float) windowHeight,
                        faintestMagNight);
starRenderer.starVertexBuffer->render();

Immediately after them, add these lines:

Code: Select all

glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);

Let me know if that fixes the problem . . . this could have been the cause of some other weirdness as well.

--Chris

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Post #5by chris » 25.02.2002, 18:50

I forgot to mention that the above code is in render.cpp. If that suggestion doesn't work, try commenting out this line in render.cpp:

Code: Select all

renderParticles(glareParticles, observer.getOrientation());


--Chris

[/code]

Topic author
bruckner
Posts: 79
Joined: 30.01.2002
With us: 22 years 9 months
Location: Villaviciosa de Od?n, Madrid, Spain

No change

Post #6by bruckner » 25.02.2002, 21:20

Unfortunately, none of these changes (nor its combination) prevented the bug. I wish I could help you with code... but I will eagerly compile & test anything you like.

Did I mention that .cms meshes dont suffer the problem (and don't accept Color [ R G B ] settings in .ssc files, by the way...)? That may help...

Best regards.

Bruckner

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Post #7by chris » 25.02.2002, 23:03

I'm looking into this bug some more . . . the fact that .cms meshes work fine is a good clue about what might be going wrong.

The color does affect .cms meshes, but you must have the line:

Code: Select all

BlendTexture true

(as many asteroids in solarsys.ssc do) in order for it to affect the color the way you want it to. Ordinarily, the color is just used to tint the object when it's distant and only visible as a point or when there's no texture applied. It's not used when rendering the object's texture unless you explicitly enable BlendTexture. For instance, Earth has a bluish color at a distance which is supposed to represent an 'average' color of the oceans and clouds. It would be incorrect to tint the Earth texture with this color.

--Chris


Return to “Development”