Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - XOrDo

Pages: [1]
1
Support / Re: Diplaced objects after a call to removeRenderTarget()
« on: February 11, 2013, 03:42:17 pm »
Okay, I'm trying to do this, by rendering a "clipping plane" to a texture the same size as the framebuffer, then use that texture in a shader to draw only pixels that lay inside that plane.

I've tested the shader and it works OK, except the plane is displaced.

To prove this, I disabled the shader completely, and left out only the code creating the texture:
Code: [Select]
texturaMapping = new NPOTTexture(1196,897, RGBColor.WHITE);
TextureManager.getInstance().addTexture("texMapeoBig", texturaMapping);

the plane itself:

Code: [Select]
plano = createPlane(PLANE_WIDTH, PLANE_HEIGHT);
//plano = Primitives.getPlane(1,160);
plano.rotateX((float) Math.PI);
plano.setAdditionalColor(RGBColor.BLACK);
plano.strip();
plano.build();
plano.translate(new SimpleVector(0.0f, 0.0f, 0.0f));

function createPlane:
Code: [Select]
private static Object3D createPlane(float planeWidth, float planeHeight) {
Object3D plane = new Object3D(2);
float repeat = 4.0f;
plane.addTriangle(new SimpleVector(-planeWidth,planeHeight,0), 0f, 0f, new SimpleVector(planeWidth,planeHeight,0),repeat, 0f, new SimpleVector(-planeWidth,-planeHeight,0), 0f, repeat);
plane.addTriangle(new SimpleVector(planeWidth,planeHeight,0), repeat, 0f, new SimpleVector(planeWidth,-planeHeight,0), repeat, repeat, new SimpleVector(-planeWidth,-planeHeight,0), 0, repeat);
return plane;

}

..and the render to Texture part, which I posted. For the record, posting the whole render code:

Code: [Select]
fb.setRenderTarget(TextureManager.getInstance().getTextureID("texMapeoBig"));
fb.clear(RGBColor.WHITE);
world.renderScene(fb);
world.draw(fb);

fb.removeRenderTarget();

world.renderScene(fb);
world.draw(fb);
fb.display();

So, if I straight comment out the render to TExture part, the plane gets render in its proper position in the screen. If I comment it back in, it is displaced (and so it is in the texture).

I think this might be related with the framebuffer and texture sizes. I am currently enforcing an atypical fb and texture size (1196, 897), because by using vuforia in order to get the proportions right I need to set the fb resolution to that of the actual video stream. Now my device's real screen is 1280x720 so I'm guessing there's some resampling involved in either process that getting them out of sync.

I hope I explained myself.

2
Support / Diplaced objects after a call to removeRenderTarget()
« on: February 11, 2013, 03:06:03 pm »
Hi,

I have used render to texture in jpct-ae in the following way:
Code: [Select]
fb.setRenderTarget(TextureManager.getInstance().getTextureID("texMapeo"));
fb.clear(RGBColor.WHITE);
world.renderScene(fb);
world.draw(fb);
fb.display();
fb.removeRenderTarget();

I paint a plane to texture, and then I texture a different plane with this rendered texture.

It works fine but after calling fb.removeRenderTarget(); the plane painted to the framebuffer is slightly displaced from its position. If I comment the first render step the plane appears in the correct position.

Is there something that I'm missing?

Pages: [1]