jPCT - a 3d engine for Java > Support

Environment Mapping with Software

(1/3) > >>

AGP:
One of my ships is shiny. I have a vague memory of talking to you about environment mapping with the software renderer. I fully expected that the environment map would not work with the software renderer, but my expectation was that the diffuse map would be completely replaced by the environment map and that the environment map would be treated as diffuse. This is not so. Ambient map acts like the ambient map but the diffuse channel disappears. To that end, I tried writing the following method. But obviously, the result is that the ambient map is just colored by the diffuse. My question, then, is since the environment mapping is already performing as expected, would it be possible to just make the diffuse channel work with it?


--- Code: ---     private void combineAmbientAndDiffuse() {
Texture tex = TextureManager.getInstance().getTexture("EnvironmentMap");
tex.add(TextureManager.getInstance().getTexture("Starfighter.png"), .5f);
     }

--- End code ---

EgonOlsen:
Just to clarify this: With "ambient map", you mean the environment map?

AGP:
Yes, sorry.

AGP:
Do you have a response?

Also, I know I keep hitting the same keystrokes but, Polyline for the software renderer? It's really very important. I wrote the following class. Even if it worked all of the time, it would still be a bit of a hack...


--- Code: ---import java.awt.*;
import com.threed.jpct.*;

public class PolylineSoft extends Polyline {
     private SimpleVector[] points;
     public PolylineSoft(SimpleVector[] points, java.awt.Color color) {
super(points, color);
this.points = points;
     }
     public void update(SimpleVector[] newPoints) {
super.update(newPoints);
this.points = newPoints;
     }
     public void draw(Graphics g, Camera cam, FrameBuffer buffer) {
Color oldColor = g.getColor();
g.setColor(super.getColor());
for (int i = 0; i < points.length-1; i++) {
     SimpleVector p1 = Interact2D.project3D2D(cam, buffer, points[i]);
     SimpleVector p2 = Interact2D.project3D2D(cam, buffer, points[i+1]);
     if (p1 == null || p2 == null)
continue;
     g.drawLine((int)p1.x, (int)p1.y, (int)p2.x, (int)p2.y);
}
g.setColor(oldColor);
     }
}

--- End code ---

EgonOlsen:
The software renderer doesn't support multiple texture layers. Or at least not in the way in which the hardware renderer does. You could use a different path for the software renderer and use setBlending(true). Then assign three textures to it (diffuse, envmap and envbump) but use a single colored texture with (128/128/128) as color value for the envbump texture. That should give you some kind of blending between diffuse and env.

Navigation

[0] Message Index

[#] Next page

Go to full version