• Content count

  • Joined

  • Last visited

Community Reputation

140 Neutral

About Frederick

  • Rank
  1. Use BackBuffer as Texture Input

    Hey thanks! ok, when I think about it seems logical to me now [img][/img] [quote]You can't do this directly as you would be both reading from and writing to the same GPU-side resource at the same time, so you have two main options.[/quote] Of course I would read the background, warp it and then render the front of the object on top of it. Doing that at the same time can´t work on a logical level... did not quite see that before [img][/img] I guess I will go with the framebuffers then, no problem at all when post effects are applied (at some point in the future). They need offscreen buffers anyway. Thanks!
  2. 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
  3. [java] Deploying to I Pad

    Hi CaptainJester - I probably will ! If LWJGL works on Android thats great news. I have a fair chance then to get my framework working as well. I looked into LWJGL, but chose to "roll my own" (TM), to keep in control of things . Anyhow I would be interested how LWJGL was compiled for Android. If you could give me a pointer to compilers/development tools that would be awesome! Cheers, Frederik
  4. [java] Deploying to I Pad

    [quote]just a set of arbitrary rules imposed by the only gatekeeper that matters.[/quote] Yes exactly seems pretty arbitrary to me Possibly they fear the bundled vm could be manipulated to run any non-packaged code, or something like that. [quote] iOS will, eventually (which may be next year) move towards merging the desktop and mobile markets.[/quote] Hmm, I fear this isn´t exactly good news concerning the openess of the apple computer platform. [quote]Recently there was a discussion on project management. One of huge mistakes developers make is [url=""]sunk cost fallacy[/url]. If you want to monetize your game, then port it and earn hard cash.[/quote] I see that... but I like the project the way it is. It has turned out nice - it was a little work to setup java with c++, but overall it does me good. I can think of an obj-c port, when I have accomplished something with my work, but at the moment I should really concentrate on moving on, otherwise I won´t get done anything. I am already developing every tiny bit by myself and thats so extremly time consuming - I just have to concentrate on results by now. Of course I think of some monetization and reaching the right audience. Don´t want to get rich, but maybe finance quarter/half of month salary or something like that. Just a dream of going indie... [quote]Otherwise, accept that current project isn't viable on iOS.[/quote] Right, thats a bit sad. But maybe there will be alternatives in a year or two - I hope so. Thanks for clearing that up, Frederik
  5. [java] Deploying to I Pad

    [quote]Use Obj-C. "It's not a big deal".[/quote] When it was not clear from my first post: I have already heavy invested in the java platform. When I started work on the project, the I-Pad most likely didn´t even exist as a concept. Using Obj-C is just not an option. Although it is based on smalltalk, which is good, it is a niche solution forced on to the developers by apple. No point in rewriting a non trivial codebase. So its not about proving anything. I just want to know, if there is any way to release on i-pad. Technically there is no problem at all. It is all about Apples proprietary business model. [quote] Which will further complicate issues.[/quote] C/C++ is legal on the I-Pad. gcj would produce code that is possibly undistinguishable von "normal" C/C++. just searching for options here. >You cannot deploy via AppStore, which is the only way such applications can be distributed. Thats sad. I guess the conditions are different to the MacOS AppStore. Here is a solution for Mono But I guess its not valid for i-pad. [quote]Such applications cannot be realistically distributed so they defeat the purpose.[/quote] As I said my project is older than the i-pad and in these times java was a totally viable option on maxosx.
  6. Hi, I am a german student, who is working on his private game project in his spare time 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
  7. ETA for a from scratch 3d GFX engine?

    Hi, I have been starting totally from scratch and use only basic library functions like font rendering, lists, hash maps and opengl of course.. I do this as a hobby next to my student job and studies. It took 3 years + and I am at the point, that I have a simple scene graph and can utilize many "modern" functions like glsl, multi pass materials, render to texture, vertex buffers. Many things are missing like collision detection, HDR, environment mapping, deferred lighting. Some of these are likely to be never implemented. I concentrate on characters on the moment as this is part of my diploma thesis: markerless motion capture. Hardware progress is running forward and I play catch up I have by no means reached my goal, so prepare for a lot of work, reading and thinking. Maybe its more clever to specialize on a certain aspect and implement that, rather than doing it "right" and implement an engine with full generic capability. You need to be patient and put lots of work in it. Actually I don´t know if i will ever finish a game, but it has taught me so much, I might eventually get a job in the field, at least have some chances. I continue nevertheless... Cheers, Frederik
  8. Hi jyk, [quote]I've never run across that particular statement (not to say it's not out there somewhere).[/quote] This is from wikipedia. Maybe this is right for angular representations only. But I have definitelty seen relaxations of this sentence stating that 3 parameters are generelly insufficient. [quote]In the same way the hyperspherical space of 3D rotations can be parameterized by three angles ([url=""]Euler angles[/url]), but any such parameterization is degenerate at some points on the hypersphere, leading to the problem of [url=""]gimbal lock[/url].[/quote] I am not too sure about the eulers though. I will try (actually my computer will ) many poses to search for one which minimizes the error to a depth image. So its not completely unlike that the problem with gimbal lock could occur. I have read about character animators who are used to work around gimbal lock I can´t exactly tell so I will try the compressed quaternion form. Thanks!
  9. Hi Geometrian, thank you so much for pointing that out. Of course it was meant as a projection matrix - and it did the visual - kind of. I took the matrix from [url=""]here[/url] But I didn´t notice that the w coordinate of the translational part of this matrix is set to zero. I thought that w of the translational part must always be one. The w value introduced the weird translation I had to fight with. Maybe I have to rethink my whole approach concerning matrices. I learned from David Eberlys fine "Geometric Tools" that it is a good idea to distinct point and vectors. And I distinct them per type. So I have a point and a vector class. Points w is always 1, Vector w is always 0. At least I thought so. I had to relax this lately because the homogenous approach to perspective division demands w values different from zero or one. My whole approach to matrices is somewhat broken now. Maybe I will rewrite them. My current approach looks like this: [quote] public class Matrix3 { private Vector3 x, y, z; private Point3 w; [...] }[/quote] Up to now I liked it and thought it was elegant, but there are cases like projection when w actually is not a point. Now i do something like: [quote]matrix3.w().setW(0.0f) [/quote] which contradicts the statement that w is of type point3. Maybe I have to abandon this approach. I also have never seen anybody do it like this - there might be a reason.... Thank you so much and extra pair of eyes can really do wonders sometimes - I was so stuck in my approach - I would have never noticed that glitch. Frederick
  10. Hi, [quote]I'm not a mathematician, so I may be inexact or even wrong.[/quote] Neither am I [quote] 1. With x[sup]2[/sup] + y[sup]2[/sup] + z[sup]2[/sup] = 1 and (x, y) given, you still cannot compute a unique z. You are only happy with this if +z and -z have the same meaning. In the case of quaternions it is true that for each orientation in 3D space 2 equivalent quaternions exist, one being the negated version of the other. But due to the square, the sign is lost anyway [/quote] Well thats interesting. The w value is not completely redundant, but stores a sign, which will disambiguate the dual rotations. Quaternions seem to cover the [i]action [/i]of rotation not only the[i] result[/i], which means not only the end orientation is stored, but also the way taken to reach it. For me that is not so important, and its totally fine to loose this extra information. [quote] 2. A rotation matrix can be interpreted as a basis. Such an interpretation is (AFAIK) not existent for quaternions. Saying "if we look at quaternion representation there is a compact axis-angle representation hidden in the four values" is wrong w.r.t. a geometric interpretation. Of course, you can convert from quaternion to axis/angle (or matrix, or Euler angles, or whatever), so in [i]this[/i] sense it is hidden therein, but I think that isn't the statement behind the sentence. [/quote] Well there is a geometric interpretation, have a look at the [url=""]wiki[/url]. Quaternion is actually axis/angle, with the axis scaled by some sine of the angle. Again the quote: [quote]he point ([i]w[/i],[i]x[/i],[i]y[/i],[i]z[/i]) represents a rotation around the axis directed by the vector ([i]x[/i],[i]y[/i],[i]z[/i]) by an angle [img][/img][/quote] [quote]3. A quaternion need not be of unit length, but only unit-quaternions represent pure rotations. So from the standpoint of the general quaternion, the unit-length is not a must and hence there is no redundancy. Just your usage may introduce this redundancy.[/quote] Right but un-normalised quaternions are not of great use, unlike unnormalised homogenous coordinates !? Or are there other use cases for quaternions ? [quote]5. AFAIK gimbal lock is a problem of consecutive rotations where a particular rotation becomes worthless because of the previous rotations. This has nothing to do with the number of co-efficients but with the method of rotations one uses to compose the overall rotation. That said, gimbal lock may occur when using quaternions or axis/angle rotations as well; you just have to use them in the same manner as Euler angles are used, for example.[/quote] Given, but it is often stated that representations with only three values are degenerate at some point. [quote]It can be shown that no two-parameter coordinate system can avoid such degeneracy.[/quote] In our case thats 3D. This doesn´t seem to apply to "axis scaled by angle". Any more enlightenment ? Actually I am favouring "scaled axis" over eulers at the moment. I believe including w would cause only trouble, since this would require the optimization process to care for the quaternion constraints. Thanks al lot! Frederik
  11. Hi, unfortunately i have found no solution for my [url=""]other[/url] 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[url=""] wikipedia quote[/url]: [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 [i]w[/i],[i]x[/i],[i]y[/i]),[/quote] So analogous we can´t represent a rotation in 3D with 3 values, but... [quote]Points on the sphere satisfy the constraint [i]w[/i][sup]2[/sup] + [i]x[/i][sup]2[/sup] + [i]y[/i][sup]2[/sup] = 1, so we still have just two [url=""]degrees of freedom[/url] though there are three coordinates.[/quote] 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: [quote]The point ([i]w[/i],[i]x[/i],[i]y[/i],[i]z[/i]) represents a rotation around the axis directed by the vector ([i]x[/i],[i]y[/i],[i]z[/i]) by an angle [img][/img][/quote] 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
  12. 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 [url=""]Mouse Ray Picking Explained[/url]): 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: [CODE] /* * 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??? } [/CODE] I would be glad if anybody could point out my error. Thanks a lot, Frederick
  13. Quote: Hey Frederick Have you done a C++ comparison? If you do it don't forget to post the results!! Hey !!! Ah, nooo, maybe that comes later, but i did another interesting test: Remember my function looked like this: public void rotate(float angle, Vector3 axis) { Matrix3 rotationMatrix = Matrix3(); rotationMatrix.loadAxisAngleRotation(angle, axis); rotationMatrix.transformOnlyOrientation(this); } which was called like this: Matrix3 matrix = new Matrix3(); Point3 p = new Point3(); for(int i = 0;i <= 24000000;i++) { matrix.rotate(0.1f * i, new Vector3(1,0,0)); p.translate(matrix.x()); } So basically, we have an allocation of Matrix3 (which has four subobjects x,y,z,w by the way) per loop iteration - right ? Running time without EA 59 seconds - with EA enabled 52 seconds. I would call that a good improvement, but the exciting thing comes now: I tried this also: Matrix3 matrix = new Matrix3(); Point3 p = new Point3(); Vector3 axis = new Vector3(1,0,0); //Moved all allocations out of the loop Matrix3 rotationMatrix = new Matrix3(); for(int i = 0;i <= 48000000;i++) { //Only assignments in here rotationMatrix.loadAxisAngleRotation(0.1f * i, axis); rotationMatrix.transformOnlyOrientation(matrix); p.translate(matrix.x()); } Now guess the running time !? 55 seconds with EA disabled and 52 seconds with EA enabled. Well I have only one word for this: MAGIC. Hotspot is real magic. I am happy and confident now that I can walk far with java. It is a super advanced modern system by now and should get credit for that. C++ test will follow If I am not lazy. I would guess 42 seconds or something, lets see ;-) Yes, Antheus is right a flat memory layout would be a great addition to handle massive collections of objects, like vertices, indices and so on. I hope some game and media oriented people will add this to the jdk. It would also make communication with c++ easier. By now I stuff everything into ByteBuffers, which are wrapped into objects on the c++ and the java side, that is a hacky workaround, but I hardly notice, what is going on behind, when I use the wrappers. So I am really happy I have no need to port my project and can happily stay. The only thing is I would like to have a reliable way to find out when allocations are omitted and when not, to get more control over that, so if anybody has a good idea I am happy to hear about. Thank you all for your great participation, I don`t think I would have drawn this conclusions by myself (-; Frederick
  14. Hey... Quote: But unless you change the code, how would you avoid that allocation hell with C++? The cool answer is, you just have to remove the "new" keyword and the object is allocated on the stack, not the heap memory. Thats really a cool feature of c++. This code is perfectly valid (and performant) c++ code public void rotate(float angle, Vector3 axis) { Matrix3 rotationMatrix = Matrix3(); rotationMatrix.loadAxisAngleRotation(angle, axis); rotationMatrix.transformOnlyOrientation(this); } When the function is called, all local variables are "bundled" together and put on the stack. Allocating objects this way is a matter of moving the stack pointer a little bit farther. So allocation cost is truly zero. Only initialization matters. When the function returns the stack pointer is moving back and all objects get auto-deallocated. Very easy, clever & powerful. But also tricky for learners because you can´t return local objects. You have to know what the language does in the background to program in c++. But... its the same with java, if you ask me. I am not an expert in C# but I think struct has value semantics, and in C# that means pass-by-value. Wouldn't it be a heavy penalty for performance? Yes it would, if you would pass the whole struct-array by value, but that is a thing you wouldn´t do. You have to copy each struct individual into its flat-memory array cell and thats in principle the same as initializing an object. Potentially it could be faster because you have the memory where the object will take place directly at hand, you preallocated it in one chunk. Think of an array, where each cell has the size of a whole object, not just the pointer as in java and you copy the objects properties directly into to the cells, not at the location of the pointer you find in the cell Quote: Can you try something like this: Yes sure. But the thing that matters most is abstraction in programming. It makes the job really many times easier. In this simple case, it might be bearable to pass only primitive types, but this really bloats the code and if you ask me, the right abstraction makes all the difference. Could it be that the profiler is interfering. Why don't you generate two compiled versions with and without the optimization and then checked the total time of maybe 100,000 thousands of operations. Yeah... wahhooo. That showed some real results. I switched back to jdk.1.6.0_16 and did a simple time-benchmark with this code: Point3 p = new Point3(); for(int i = 0;i <= 24000000;i++) { matrix.rotate(0.1f * i, new Vector3(1,0,0)); p.translate(matrix.x()); } It took 18 seconds without the EA flag turned on and 16 seconds with the flag. Thats quite a difference. Maybe I should do a C++ speed comparison. I would call this quite a good result. 2 seconds sounds reasonable as a saving when allocations are omitted. Its true, maybe the profiler interferes. The longer i think about it, the more reasonable it sounds. I believe the profiler does some kind of bytecode instrumentation and maybe replaces every allocation with a call to the profiler. Just guessing... Thank you.
  15. Hey! Thanks for your answers! Quote: mm, interesting. How much difference in performance? Frankly I can´t tell, but I don´t like to have an allocation hell going on in my project. Maybe its not a big deal in this example, but it has a potential to sum up quickly. The JMonkeyEngine guys seem to be fine - maybe I should be too...but I don´t like to run allocations out of control. Quote: Java, due to the design of its memory model, is worst possible case for this type of operations and will always remain as such. The biggest problems do not come from temporaries, but from lack of in-place array allocations. Actually that is not quite right... I use ByteBuffer objects to store all my vertices (same for matrices) and pass them to the jni c++ layer. ;-) But you are right. This is an annoying hack... but I got around with that. So no big performance hit here... I primarily chose java because I hoped for more productivity. That has been mostly right up to now, because of the great refactoring tool support, lack of header files and so on. I was also annoyed of all the small flaws of c++ one has to work around... its simply not a clean language. It would be a strange insight in my programming career that c++ might actually allow MORE intuitive programming concerning algebra than java. Frankly I like java and its dynamic nature... There are just a few flaws. EA could solve the stack allocation problem. Quote: Escape analysis under 1.6 has been shown to provide around factor of 15 performance improvement in best case How the heck do I reliably switch that thing on (Yes I tried the -XX:+UseEscapeAnalysis flag). If I am right it is as equally capable than the C++ stack scope auto-deallocation thing, plus may be more capable in future. The analysis phase takes startup time, but that doesn´t matter. I have come to believe that EA never worked in any example (That one I wrote about, was most likely a change of scala in the profiler, which seemed like lower allocation level). Has anybody perceived real results with EA and can tell me a method to reproduce that, how to enable and verify that it kicks in ? Lets take this example again: Quote: public void rotate(float angle, Vector3 axis) { Matrix3 rotationMatrix = new Matrix3(); rotationMatrix.loadAxisAngleRotation(angle, axis); rotationMatrix.transformOnlyOrientation(this); } The matrix allocation should be clearly optimized, or am I wrong about that ? Quote: But that implies that the escape analysis has to be performed through n-level indirection. I am not sure about that. I cannot deduct that from the link. Can you give me any hint? Ok you refer to my first more complicated example, keep in mind, that the simpler also does not work for me. But... I have no exact source, but I figured if that HotSpot is capable of: Quote: The method makes a copy to prevent modification of the original object by the caller. If the compiler determines that the getPerson() method is being invoked in a loop, it will inline that method. In addition to this, by escape analysis, if the compiler determines that the original object is never modified, it may optimize and eliminate the call to make a copy. Lets see: 1.)multiply is in a loop and gets inlined. 2.)transform() is in multiply and thus in a loop (the indirection you mentioned) 3.)dx is read only accessed and its pointer is not stored in a collection So the case is at least similar... why would hotspot only inline one call level. Why wouldn´t it bake the second level also into one big soup !? ,-) Not sure about that, but keep in mind, that the more obvious example I provided before doesn´t work either. Quote: Java, due to the design of its memory model, is worst possible case for this type of operations and will always remain as such. Quote: Until Java introduces C# struct-like type, it's simply not economically viable for this type of tasks. Don´t be so hard to java. Its actually a good language and HotSpot is magic. Also run-time code loading and reflection gonna be cool in gamedev. Netbeans is also superior to VS. You don´t believe ? It is... I know both ;-) There are some pieces missing. But... if an "array"-pool allocation mechanism gets added to OpenJDK and EA does work reliably the language would be there. I am too busy with game development (-:, but some compiler freaks could kick it... Till then use ByteBuffers and wrapper classes to solve the pool problem. C# is not so cross platform and I simply won´t learn another system. I like java and I don´t feel like going to c++, at least not yet. Please help me to get that damn thing going !!! Thank you for your kind attention, Frederik