Reflection efect

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

Previous topic - Next topic

Melssj5

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

EgonOlsen

#1
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.

Klaudiusz

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 :)

EgonOlsen

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.

EgonOlsen

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.

Melssj5

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

EgonOlsen

Sure. Assuming that the model already has proper texture coordinates for its base texture, just do:


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

EgonOlsen

Quote from: Klaudiusz on June 02, 2007, 05:06:03 PM
Bumpmapping in OpenGL mode is still not available, true?
No, it isn't.

Melssj5

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

Melssj5

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

EgonOlsen

This doesn't look like multi-texturing to me. Can you post the section that initializes the textures and the environment mapping?

Melssj5

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:


//after loading the 3d and before calling to addObject and before calling to buildAllObjects

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




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

Klaudiusz

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?

EgonOlsen

Quote from: Klaudiusz on June 16, 2007, 05:31:09 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.

EgonOlsen

Quote from: Melssj5 on June 16, 2007, 04:58:48 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... ???