Author Topic: Reflection efect  (Read 20604 times)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Reflection efect
« Reply #15 on: June 16, 2007, 08:42:00 pm »
Here'a an example of what i was talking about: http://www.jpct.net/download/tmp/viper.zip

Offline Klaudiusz

  • int
  • **
  • Posts: 75
    • View Profile
Re: Reflection efect
« Reply #16 on: June 16, 2007, 10:43:01 pm »
Well i just found there is also:

Quote
CurrentObject.calcTextureWrapSpherical();

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

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Reflection efect
« Reply #17 on: June 17, 2007, 04:26:46 am »
<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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Reflection efect
« Reply #18 on: June 17, 2007, 12:40:09 pm »
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.

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Reflection efect
« Reply #19 on: June 17, 2007, 06:47:16 pm »
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

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Reflection efect
« Reply #20 on: June 18, 2007, 05:34:53 pm »
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Reflection efect
« Reply #21 on: June 18, 2007, 06:01:35 pm »
That would be very helpful. My guess is, that you are simply using a not so appropriate texture, but we'll see...

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Reflection efect
« Reply #22 on: June 19, 2007, 07:48:52 am »
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.
« Last Edit: June 19, 2007, 07:52:20 am by Melssj5 »
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Reflection efect
« Reply #23 on: June 19, 2007, 06:17:56 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Reflection efect
« Reply #24 on: June 19, 2007, 06:30:07 pm »
BTW: The javadoc should be upgraded on the IRENDERER modes.
They are bit sparse indeed. What information exactly are you missing?

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Reflection efect
« Reply #25 on: June 19, 2007, 08:18:53 pm »
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Reflection efect
« Reply #26 on: June 19, 2007, 08:59:57 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Reflection efect
« Reply #27 on: June 20, 2007, 12:05:35 am »
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:

Code: [Select]

        /**
* 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.

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Reflection efect
« Reply #28 on: June 20, 2007, 04:40:49 am »
ok I will test it now
Nada por ahora

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Reflection efect
« Reply #29 on: June 20, 2007, 05:35:38 am »
Yes it worked! Now I sill fix my model to avoid reflecting all the side. Thanks a lot.
Nada por ahora