Jump to content

  • Log In with Google      Sign In   
  • Create Account


Frederick

Member Since 03 Nov 2006
Offline Last Active Nov 13 2012 02:56 AM
-----

Topics I've Started

Use BackBuffer as Texture Input

06 November 2012 - 11:24 AM

Hi Guys!

I´d like to implement a refraction like effect, and would like to warp the "background" of the object in some way.
As the object is marked as translucent it is rendered in a separate queue after the opaque objects - so it can be assumed that at this
stage the background has been fully drawn.

Is it possible to use the actual BackBuffer as Texture Input or do I have to render to the scene to a separate RenderTexture and perform the read from this texture ?

I would like to avoid the additional copying that is involved with that.

Thanks a lot,
Frederick

[java] Deploying to I Pad

26 August 2011 - 09:17 AM

Hi,

I am a german student, who is working on his private game project in his spare time :wink:
Just as a note: I am FAR away to release anything, but I might someday...

And I wonder if could release on I-Pad then. I absolutely dislike Apples closed devices, but it is
good way to reach average joe users and the device itself is cool.

As a one-man-show i decided to use java and believe that was a good decision because of its very mature and powerful
tools (Netbeans refactoring).

I wrote my own jni layer around opengl, so there will be some c++ compiling and dll loading too.

Here my question:
Is there any possibility to get on the i pad legally ? This information is kinda hard to find.

There are several ways, that might work:
-Strip OpenJDK, compile the jvm for i-pad and bundle it with the game. Might be tricky, but could work. I don´t need swing etc. at all. Only basic datatructures (HashMap, linked list etc.),
BufferedImage,BufferedReader (could roll own versions of that too).
-Use gcj (What about reflection ?)
-Excelsior Jet (pricey ;-))

Would it even be legal to do so ? I kinda read about ridicolous rules against crosscompiling - that would be bad. :(

Hope to find the people, who know about gaming, java and the i pad in this forum !!!

Thanks,
Frederick

Orientation representation: Is it really true that all representations with 3 values su...

21 March 2011 - 08:35 AM

Hi,

unfortunately i have found no solution for my other problem, so I will have to live with that.

But in my quest for the shortest adequate representation of 3D rotations for my diploma thesis I ran into some questions, I can´t answer myself. I will
ask my prof, but I try here too, because I expect that the practical understanding of quaternions and rotations is actually better in the gaming community.

If you are interested: my project is about motion capturing, formulated as an optimization problem with approximate 25 degrees of freedom. So it is really important
to have short representations for rotations (matrices are no option).

My question:

Looking at this wikipedia quote:

It can be shown that no two-parameter coordinate system can avoid such degeneracy. We can avoid such problems by embedding the sphere in three-dimensional space and parameterizing it with three Cartesian coordinates (here w,x,y),


So analogous we can´t represent a rotation in 3D with 3 values, but...

Points on the sphere satisfy the constraint w2 + x2 + y2 = 1, so we still have just two degrees of freedom though there are three coordinates.


We can note that one coordinate is always redundant, because w^2 = 1 - x^2 - y^2. Why bother about the w ? Isn´t it a bad approach to store redundant values, which can be inferred easily ?

Actually if we look at quaternion representation there is a compact axis-angle representation hidden in the four values. Actually the first three values x,y,z denote a vector which acts as a rotational axis. The angle is encoded as the axis length. Maximally short and elegant if you ask me.

Back up:

The point (w,x,y,z) represents a rotation around the axis directed by the vector (x,y,z) by an angle Posted Image


We have an axis-angle representation realised by now, with actually three values rather than four and to my best knowledge, axis angle representations do not suffer from gimbal lock. But why is it stated on a regular basis, that there is no gimbal lock free representation with three values and why is a redundant value stored in the quaternion representation ?

I am sure someone can shed some light in my dark ;)

Cheers,
Frederik

Unprojection of points / Homogenous clip coords make me perplex

18 March 2011 - 04:08 PM

Hi,

i have been spending a lot of time to track a bug in my projection pipeline. I am implementing ray picking for my diploma thesis - actually just a UI thing
I did not plan to waste so much time on it.

I used two different methods to unproject:
1) Place an imageplane in front of the camera and shoot a ray
2) Invert the projection matrix multiply and homogenize

In both cases i observed that the generated rays were a little of and missed the scene parts they were suppossed to hit slightly. Just because I ran out of ideas
I translated the ray origin to (0,0, -1) and suddenly it worked perfectly.

I could ignore that little glitch, but it leaves me with a bad feeling as I do not understand what happens behind the curtains. The ray origin should be (0,0,0) - right ?

As I ran into the problem twice, I suppose I did fail to understand all aspects of homogenous clip coordinates. I will post my projection matrices and maybe you guys could
give me some advice what I am doing wrong - This is really starting to frustrate me.


My viewport to NDC matrix (row vectors):

x: (1.0f / (width / 2.0f)), 0, 0 ,0)
y: (0, (1.0f / (height / 2.0f)), 0 ,0)
z: (0, 0, 1 ,0)
w:(-1.0f 1.0f 0 ,1)

My projection matrix: (symmetric frustum)

x: (near / right, 0 0 0)
y: (0 near/top 0 0)
z:(0, 0 (far + near)) / (far - near) 1) //Camera is looking in positive z, opposed to vanilla OpenGL
w(0, 0 -(2 * far * near) / (far - near) 1)


The inverse projection matrix (after Mouse Ray Picking Explained):

x: (right / near, 0 0 0)
y: (0 top / near 0 0)
z: (0 0 0 (far - near) / (-(2*far*near))
w:(0 0 1 (far + near) / ( 2*far*near))

I am not sure the matrices will help, but maybe you got an idea what i might have forgot ?

The actual method (java) looks like this:
 /*
  * Returns a ray in eye space
   */
  public Ray raycast(Point2 position) {
   	//Viewport to NDC
   	Point3 pickPoint = paintingSurface.normalise(new Point3(position, 0));

  	//NDC to eye coordinates
   	Point3 reprojectedPoint = inverseProjection.multiply(pickPoint);
   	reprojectedPoint.homogenousDivide();

   	Vector3 rayDir = reprojectedPoint.subtract(Point3.ZERO);
   	rayDir.normalize();

   	return new Ray(new Point3(0,0,-1), rayDir);   /// :-(((((( Why???
	}

I would be glad if anybody could point out my error.

Thanks a lot,
Frederick

[java] Perfomance vs. improved readability (Escape analysis does not work!?)

01 May 2010 - 01:13 PM

Hi, I need some help from serious java game developers. At the moment I am revisiting my matrix code. My previous version was basically an array of values. Unfortunately this is not the most intuitive way to deal with matrix programming. This time i tried a more OOP style:
public class NewMatrix3 {
    private Vector3 x, y, z;
    private Point3 w;
     ...
}
The matrix has now subobjects, which bring their own methods. From a programming point of view this makes lots of things easier (at least in my opinion =)) Particularily I tried this:
    public Point3 multiply(Point3 p) {
        Point3 r = new Point3(w);

        Vector3 dx = x.multiply(p.getX());
        Vector3 dy = x.multiply(p.getY());
        Vector3 dz = x.multiply(p.getZ());

        r.translate(dx); r.translate(dy); r.translate(dz);

        return r;
    }

The purpose of this method is to transform a point in space by the matrix. The method is unorthodox, but much more visual than plain row/column dot-product multiplication. The result point is translated into the origin of our coordinate system and a linear combination of the axis vectors is added to the origin point. So mathematically all should be right ?!! Hope so, but thats not the point. We have a method here with at least 3 local objects, the vectors dx, dy, dz, which are allocated inside the scalar multiply method of vector3. When I understand right, these are perfect candiates for escape analysis. Thats a thing I really dislike about java... code like this is simply not feasible from a performance standpoint (at least it was), but is perfectly fine in c++ ;-( I really would appreciate to write like this. So I tried this: -server -XX:+DoEscapeAnalysis with a small test program:
 NewMatrix3 matrix = new NewMatrix3();
        matrix.loadAxisAngleRotation(30, new Vector3(1,1,1));
        Point3 p = new Point3();
        for(;;) {
            p.set((float)Math.random() * 100f, (float)Math.random() * 100f, (float)Math.random() * 100f);

            Point3 r = matrix.multiply(p);

            System.out.println(r.getX());

        }
Unfortunately there is NO difference to no escape analysis at all. The netbeans profiler reports a hell of lots of Vector3 objects that are allocated. But if I got this right, none should be allocated at all. I really appreciate some help. Because I like java and there are advantages to come later on in game programming, like good scripting support, continuations via javaflow, reflection, low compilation times, runtime code loading. But this sacrifice of readability in exchange for performance is really a pain. I am even thinking of porting my project to C++... :-( I would really appreciate help in this case. Btw. escape analysis seems to work somehow, as it lowered total object creation in my main program. So it does at least something. But i believe the example I provided should be the standard case for escape analysis and should provide a stellar speed up, shouldn't it ?! Thank you! Really desperate for help, Frederick

PARTNERS