Reflection efect

Started by Melssj5, May 26, 2007, 04:54:14 PM

Previous topic - Next topic

EgonOlsen


Klaudiusz

Well i just found there is also:

QuoteCurrentObject.calcTextureWrapSpherical();

Very usefull in reflection effect,when You don't have UV. GJ Egon:)

Melssj5

<What i was thinking of when posting the code snipped was an object textured normally but with a kind of "reflective layer" on top of it.>

Exactly. But you saw the result. The color is not the one I put, irs much more whity that the original and the enviroment map was almost black.

When I put any texture to the car it is always shown as a full unique color.
Nada por ahora

EgonOlsen

Then have a look at the example that i've posted to see if that is, what you want and try to adept it to your case.

Melssj5

ok, I saw the exmple and that is what I want, I will check the code but I am 100% that my problem is my car model, anyway I will check it.
Nada por ahora

Melssj5

Well, the code on the example is exactly the same I was using first, well my enviroment map was like full stars and make that effect. Anyway, my problem is now the base color of the object. it change a lot when I apply the enviroment map. I mean, it becomes very shinny.

I modelled another car, took me about 9 hours to have an own model but anyway, the results were the same, except that this new model is too heavy (1.2 MB) and make everything go slow. At night I will post the app to see if anyone can help me.
Nada por ahora

EgonOlsen

That would be very helpful. My guess is, that you are simply using a not so appropriate texture, but we'll see...

Melssj5

#22
ok, posted, the link is:

the problem is that it becomes very shinny, the original blue is at the beggining and the desired colors can be seen on the car demo on the download section, they are the same textures for the replacement. It also runs very slow on GLCanvas but fast on normal OGL.

please dont laugh at my model, I spent 9 hours doing it.

www.soft-ec.com/Demos/carro.zip

BTW: The javadoc should be upgraded on the IRENDERER modes.

PD: Its so shinny that even without any light nor an ambient light I can see it.
Nada por ahora

EgonOlsen

As far as i can see, everything is technically correct. The visual effect (or defect...) mainly comes from a sub optimal environment map. Try to darken the texture or use another one (the one used by me in that "viper example" is a bit too subtle for your car...something in between may work fine). Plus, the model has very flat sides, which leads to a kind of on/off-reflection when viewing it from the side, because all vertex normals of the whole side are pointing into the same direction. You may also try to play around with the blending mode used the apply the base map.
It's all a question of art in this case, i'm afraid.

EgonOlsen

Quote from: Melssj5 on June 19, 2007, 07:48:52 AM
BTW: The javadoc should be upgraded on the IRENDERER modes.
They are bit sparse indeed. What information exactly are you missing?

Melssj5

so,its normal to get a so shinny result texture? Then I wont be able to exactly control the resultant color. Well, about the flat sides,I already noticed that but that was a modelling stuff that is easy to fix but I was worried about the shinnyness,  it seems to have self illumination becausse even without lights it appear and I guess it shouldnt becausse I wont even be able to control the visualization playing with the lights! Can this be "fixed" assuming its a problem!?!?!?

I thought that the IRENDERER fields had new names but I guess I was wrong. I was tired when wrote that.
Nada por ahora

EgonOlsen

Quote from: Melssj5 on June 19, 2007, 08:18:53 PM
it seems to have self illumination becausse even without lights it appear and I guess it shouldnt becausse I wont even be able to control the visualization playing with the lights! Can this be "fixed" assuming its a problem!?!?!?
And finally, i understood your problem... :) Well, the behaviour itself can't be fixed. It's caused by the OpenGL pipeline which works like this when using multi-texturing:



As you can see, vertex colors are being applied first, then modulated (always, you can't change this) with the first texture stage's output. The result will be taken and blended with the second stage...etc. In your case, the second stage blends using ADD, which simply adds the color. Because this stage contains the base texture and the lights are off, you end up with 0+base_color=base_color which is why the model looks so bright even with no vertex lighting being used.
I'll have a look at this behaviour. Maybe it's possible to shift the enviroment mapping to the second layer somehow. In the meantime, you may play around with other blending modes like MODULATE, which doesn't suffer from this problem.

EgonOlsen

Ok, i've added support for shifting the environment map to the second texture stage if available. This is kinda hacky, so i'm not sure that it works 100%. Anyway, here's the jar: http://www.jpct.net/download/beta/jpct.jar

and here are the docs for a new setting in Config:


        /**
* By default, an environment map will be applied to the first texture stage if
* environment mapping is used on an object. When combining it with multi texturung,
* this may not always be want one wants, because the lighting calculations of OpenGL
* may give you undesired results by applying the lighting to the environment map
* instead of the base map. To work around this problem, you can force jPCT to use the
* second texture stage for environment mapping, if (and only if) the object uses multiple
* stages. However, jPCT doesn't check if a particular polygon uses multiple stages. So
* if you are forcing environment mapping to stage 2, make sure that your multi textured
* object all have that stage for all polygons and that the correct textures are assigned.
* Default is false.
*/
public static boolean glForceEnvMapToSecondStage=false;


To use it in your app, set it to true and swap the texture assignments in the TextureInfo-creation. Please let me know if this fixes your problem somehow.

Melssj5

Nada por ahora

Melssj5

Yes it worked! Now I sill fix my model to avoid reflecting all the side. Thanks a lot.
Nada por ahora