Author Topic: Reflection efect  (Read 20408 times)

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Reflection efect
« on: May 26, 2007, 04:54:14 pm »
Hi, how can I get a reflection efect over an object3d? like in the fps demo on the weapon. The object3d wont act like a mirror, only want to get that effect. Its for placing in over a car.

Can I have it together with another texture?
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Reflection efect
« Reply #1 on: May 26, 2007, 06:03:53 pm »
The effect is simple environment mapping. You can enable it on any object. Combining it with another texture is possible by using multitexturing but to be honest, i've no idea how jPCT currently behaves when you enable environment mapping on an object with multiple textures. I think that the best idea would be to limit the environment mapping to layer 0 only, but i'm not sure that i did it that way. I suppose not...i'll have a look at this next week.
« Last Edit: May 26, 2007, 07:04:55 pm by EgonOlsen »

Offline Klaudiusz

  • int
  • **
  • Posts: 75
    • View Profile
Re: Reflection efect
« Reply #2 on: May 27, 2007, 11:07:12 am »
Egon,

You made great work with implement tex+env and tex+env+bump in software mode but personally i can't use it because it's not implement in OpenGL mode :( Is there any chanse toimplement it also on OpenGL?

Objects with texture and envmap are really beautyfull :)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Reflection efect
« Reply #3 on: May 27, 2007, 11:54:53 am »
As said: I'll have a look at it and i'll most likely limit env-mapping to the first texture layer. That way, you'll be able to create an effect similar to that of the software renderer. Just the setup will be a little different.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Reflection efect
« Reply #4 on: May 29, 2007, 10:03:36 am »
Ok, i had a look at it: It's already implemented in the way that i've decribed, i.e. the env-mapping is applied to layer 0 only. This means that you can set your environment map as the first texture and the normal texture as the second with an appropriate blending mode (modulate for example) and you should get the desired effect.

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Reflection efect
« Reply #5 on: May 29, 2007, 04:05:45 pm »
Ok, great the problem is that I dont know how to apply that. can you give a code example of that multitexturing stuff?
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Reflection efect
« Reply #6 on: May 29, 2007, 04:19:02 pm »
Sure. Assuming that the model already has proper texture coordinates for its base texture, just do:

Code: [Select]
TextureInfo tis=new TextureInfo(tm.getTextureID("environment map"));
tis.add(tm.getTextureID("normal texture"), TextureInfo.MODE_ADD); // Or another mode...
yourObj.setTexture(tis);

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Reflection efect
« Reply #7 on: June 02, 2007, 05:07:49 pm »
Bumpmapping in OpenGL mode is still not available, true?
No, it isn't.

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Reflection efect
« Reply #8 on: June 16, 2007, 02:59:15 am »
OK, finally I could test it and didnt worked as expected. I was thinking on something put over a texture, my actual app replace a texture on the texture manager allowing it to change the parts of the Object that has that Texture, but on that way the new Texture is applied to all the object.

Later I will post some shots about the result.
Nada por ahora

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Reflection efect
« Reply #9 on: June 16, 2007, 05:58:42 am »
Well, know I know how to use it. The problem is that is being applied to all the object and not only to the section I wanted but in anyway.

The problem now is the uvw coordinates. the car model I used was downloaded from 3dcafe when it had the free stuff online, and the textures are not being applied well. So when used the multitexture is becomes very.... mmmm...... shinny or something. Anyway the efect I got on the car wasnt the expected but was cool in anyway, I wanted it to be like is the car body reflects on somehow the enviroment but I got a efect like if the car were made of somehow of reflective crystal. I like it but is not what I am looking for. Is there anyway to remove the textures and coordinates from the msp using jpct?

Here I left a (slow) video taken with fraps and passed to movie maker to reduce its size. The video is not as good as the original becausse passed for 2 programs. I also tried getting the shots to make an animated gif but on the pic number 170 I realized that was too heavy for a gif so I made this wmv.

have a look is just 2.18 MB.

www.soft-ec.com/Video/carro.wmv
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Reflection efect
« Reply #10 on: June 16, 2007, 11:17:40 am »
This doesn't look like multi-texturing to me. Can you post the section that initializes the textures and the environment mapping?

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
Re: Reflection efect
« Reply #11 on: June 16, 2007, 04:58:48 pm »
The problem are the texture coordinates of the car, because when applied to the circular base i got the desired effect but on the car not.

the code is:

Code: [Select]
//after loading the 3d and before calling to addObject and before calling to buildAllObjects

carro.setEnvmapped(Object3D.ENVMAP_ENABLED);
carro.setEnvmapMode(Object3D.ENVMAP_WORLDSPACE);


Code: [Select]
//for changing the color.
manejadorTexturas.replaceTexture ("AZUL.JPG", texturaActual);
        TextureInfo tis=new TextureInfo(manejadorTexturas.getTextureID("MAPA.JPG"));
        tis.add(manejadorTexturas.getTextureID("AZUL.JPG"), TextureInfo.MODE_ADD); // Or another mode...
        carro.setTexture(tis);


as said before th problem is when apply that to the car becausse on the base it works well. How can I remove the coordinates info?
Nada por ahora

Offline Klaudiusz

  • int
  • **
  • Posts: 75
    • View Profile
Re: Reflection efect
« Reply #12 on: June 16, 2007, 05:31:09 pm »
The reflection efect looks great but sometime object 3d is too big to use UV.

Can i set one texture as ENVMAP_WORLDSPACE and secound as ENVMAP_CAMERASPACE?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Reflection efect
« Reply #13 on: June 16, 2007, 08:06:11 pm »
Can i set one texture as ENVMAP_WORLDSPACE and secound as ENVMAP_CAMERASPACE?
On the same object? No. Only the first texture stage will be environment mapped. All others are simply using the u/v-coordinates assigned to that stage.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Reflection efect
« Reply #14 on: June 16, 2007, 08:10:14 pm »
as said before th problem is when apply that to the car becausse on the base it works well. How can I remove the coordinates info?
The code looks fine to me so far...but i don't get the problem with the texture coordinates that you describe. I'm not sure how exactly you want it to look like. 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. For that, you need to assign the enviroment map as the first layer and the normal texture as the second. I'm not sure why you want to remove the texture coordinates for the second one... ???