Author Topic: EDA221 - Introduction to 3D 2010 HT1  (Read 39496 times)

Offline MathiasHaage

  • Newbie
  • *
  • Posts: 33
EDA221 - Introduction to 3D 2010 HT1
« on: 2010-08-30 10:53:06 »
Welcome to the course forum. Here you can report problems and bugs, ask questions and discuss course topics.
« Last Edit: 2010-08-30 10:55:22 by MathiasHaage »

Offline Daniel

  • Newbie
  • *
  • Posts: 18
Terminating with code 1 - workaround
« Reply #1 on: 2010-09-09 22:12:43 »
I had trouble running the first assignment at my home computer at first (having a ATI card might have something to do with it). When running the program it just terminated at startup with a code 1. Fortunately I found the problem and also a workaround!

During the setup of RenderChimp Console::Init() is called which in turn creates some shader(s), however on my system successfully creating a shader seems to generate a warning stating the operation was successful. The warning is supposed to be written to the console apparently, but since the console isn't done initializing the program exits instead...

If the program exits with a code 1, you can try this fix.

In the src/Result.cpp go to line 127 and comment the whole else if statement to ignore that the Console hasn't been initialized:
Code: [Select]
} else if (type != RESULT_NEUTRAL && type != RESULT_SUCCESS) {
    ResultRelease();
    exit(1);
}

« Last Edit: 2010-09-10 10:01:51 by Daniel »

Offline MrAndersson

  • Full Member
  • ***
  • Posts: 142
Re: EDA221 - Introduction to 3D 2010 HT1
« Reply #2 on: 2010-09-13 09:07:10 »
Hmm.. like with all bugs, this is peculiar... :)

If you get a warning even before the console is initiated it usually means that something has gone very wrong... Unless it is able to compile the default shaders you might get very strange behavior. I think, however, this could have something to do with the difference between ATI and nVidia drivers. I haven't tried it, but I suspect that if your fix works, the ATI driver reports shader compilation success with a message, whereas the nVidia driver is silent. RC interprets these messages from GL as warnings, because this how shaders report its warnings. Apparently this might not always be case with ATI it seems.
Again, I'm not 100% sure that this is the problem, but it does sound like it. Please let me know if this doesn't seem to apply in your case.

Commenting out that block might result in odd crashes later on, if something actually didn't initiate correctly, but if RC runs fine after it, then this fix is probably OK. I think you could also replace the if-statement with this:

} else if (type != RESULT_NEUTRAL && type != RESULT_SUCCESS && type != RESULT_WARNING) {

and it should only crash if you have a really nasty error (such as your card doesn't support shaders or something equally fatal). I chose not to allow warnings in the setup, since it may result in more hard-to-debug errors later on. Although apparently it seems that it can backfire :) I'll fix it until the next assignment.

If you know anyone else with the same problem, please share the info on how to fix it.

Also remember to check log.txt to retrieve any errors or warnings that RC might produce. Even if it crashes, events leading up to it will most likely be in that txt-file.


Offline Daniel

  • Newbie
  • *
  • Posts: 18
Re: EDA221 - Introduction to 3D 2010 HT1
« Reply #3 on: 2010-09-14 07:45:20 »
The messages I get from glGetShaderInfoLog(...) looks more or less like: "Vertex shader was successfully compiled to run on hardware."

Wouldn't a better fix be to cause a shader which is successfully compiled to report a RESULT_NEUTRAL message instead of a RESULT_WARNING? When a shader fails to compile a RESULT_WARNING is also reported, which perhaps should cause the program to terminate if it happens before the console is initiated.

I haven't worked with shaders before, but if the shader successfully compiled, will warnings ever actually be serious?

Offline MrAndersson

  • Full Member
  • ***
  • Posts: 142
Re: EDA221 - Introduction to 3D 2010 HT1
« Reply #4 on: 2010-09-14 09:17:18 »
Yes, that's what I suspected. nVidia drivers are silent (no string returned) when shader compilation is successful, and gives information only if something has gone wrong (including warnings), and therefore RC (wrongly) interprets the returned string as a warning, regardless of the actual message. (This code has been tested and works in Pluto, and the behavior is the same (though it is actually incorrect)).

And yes, for assignment 2 it will report the info log as NEUTRAL, but since you already discovered how to fix it in Result.cpp, I didn't want to confuse you or anyone else reading this by suggesting a code change deep in RC's gut. Just stick with the change Result.cpp for now and for the next assignment it'll be fixed.
With the fix suggested, if the program actually doesn't compile (generates a genuine warning) the program will crash ungracefully, but I guess this is not the case for you now?

You can run shaders with warnings, of course, but the behavior can be undefined (such as using an uninitialized variable for example). The default shaders handling text, console, etc etc should really compile without warnings to ensure that there is no undefined behavior. When you will work with shaders later on in later labs you might get loads of warnings, and it'll still run. It's only RC's own default shaders that should have the "no warnings restriction".

Thanks for catching this bug btw! The code has undergone a lot of changes this year (and there is a lot of code too!), so keep posting if you suspect that RC isn't doing exactly what it should. I admit that I haven't run it too much on ATI-hardware, which is also why there might be more of these kind of unforseen differences. (The base requirement for the code is just that it should run on the machines in Pluto.)

Offline MrAndersson

  • Full Member
  • ***
  • Posts: 142
Re: EDA221 - Introduction to 3D 2010 HT1
« Reply #5 on: 2010-09-14 17:09:45 »
Unfortunately we caught another more serious bug...

It appears that unless you actually perform a transformation on a child node to a child node to a node (i.e. no transformation for two or more levels of nodes), RC doesn't properly update the World matrix for the child on the highest level (and successive levels).
The result of this is that might not see a correct inheritance of transformations down through your scene graph, when using 3 or more levels, where some levels are not transformed each frame.

I hope this doesn't affect the understanding of the concept of hierarchical transformation too much!

There is a simple fix to this: Simply call YOURNODE->translate(0.0f, 0.0f, 0.0f); on all transformable nodes, and RC will tag the node for update.
The line will not really affect the transformation of your nodes, since it basically moving it to the same place it is currently at.

If you rotate each node of your scene graph (which you probably will, since you'll want to rotate your planets) then you won't experience this bug.

Apologies for the inconvenience! The problem will, of course, be fixed for the next assignment. Please let us know if you catch anything else, or just have questions!

Offline MathiasHaage

  • Newbie
  • *
  • Posts: 33
Re: EDA221 - Introduction to 3D 2010 HT1
« Reply #6 on: 2010-09-16 20:43:15 »
Regarding absolute and relative translation:

->setTranslate(x,y,z) = absolute

->translate(x,y,z) = relative

all transform methods have both variants.

Offline MathiasHaage

  • Newbie
  • *
  • Posts: 33
Re: EDA221 - Introduction to 3D 2010 HT1
« Reply #7 on: 2010-09-16 20:55:58 »
Regarding documentation:

There seem to be not enough information available in the source to create useful documentation. We will continue to show code examples on the seminar slides. For further info, unfortunately, this year your options are to examine the code yourselves or ask questions in the forum.
« Last Edit: 2010-09-16 20:58:23 by MathiasHaage »

Offline MathiasHaage

  • Newbie
  • *
  • Posts: 33
Re: EDA221 - Introduction to 3D 2010 HT1
« Reply #8 on: 2010-09-17 16:44:11 »
A few ideas what can be done in assignment 2:

Spaceship following a Catmull-Rom path.

Comet following an elliptic path (Catmull-Rom) with the sun at one locus. Manufacture a "bumpy" comet by disturbing the vertices of a tesselated sphere. Remember that the comet should move fast close to the sun and slow far from the sun. A comet also usually has a tail that gets longer the closer to the sun the comet is. The tail is always pointing away from the sun. The tail can modeled as a particle system with particles moving from the comet and backwards. Re-use particles, i.e. reposition from end-of-path to start-of-path, when they reach the end of the tail, do not create new particles.

Asteroid belt with tumbling "bumpy" asteroids, each asteroid looking different and following its own path, slightly different (randomized) from the others.

Programmatically generated space flights between planets (might require some work).
« Last Edit: 2010-09-17 17:02:02 by MathiasHaage »

Offline MathiasHaage

  • Newbie
  • *
  • Posts: 33
Re: EDA221 - Introduction to 3D 2010 HT1
« Reply #9 on: 2010-09-20 09:26:34 »
Hej,vi har en fråga angående interpolationsmetoderna i Interpolation.cpp som ska implementeras. Metoden för lineär interpolation definieras som:
vec3f evalLERP(vec3f &p0, vec3f &p1, const f32 t, const f32 x)
Och i handledningen beskrivs den lineära interpolationsmetoden (om man multiplicerar ihop matriserna) som:
p(x) = p0(1-x) + p1x, där 0<=x>=1 och p0 och p1 är punkter i rummet.
Frågor:
Vi förmodar att parametern t till funktionen är ett mått på antal punkter (upplösningen i interpolationen), är det korrekt?
Varför behövs paramtern x? Man vet ju att den ska variera från noll till ett.
Och varför returneras en 3vektor? Borde man inte returnera alla interpolationspunkter? eller är det (dx,dy,dz) som returneras? Eller ( {x}, {y}, {z} )?
Om du tycker att svaren på de här frågorna är till för mycket hjälp får du gärna hänvisa mig till litteratur som förklarar det. Vi har letat i boken, assignment.pdf, föreläsningsslidsen (behandlar 2dimensionell interpolation) samt internet utan större framgång. Tacksam för svar.

Offline ic07jb7

  • Newbie
  • *
  • Posts: 5
Re: EDA221 - Introduction to 3D 2010 HT1
« Reply #10 on: 2010-09-20 11:18:33 »
I am trying to get the new project from the new zip (RC_assg2.zip) to work at home. But I get this error when I compile the project:
Code: [Select]
...\rc_assg2\src\transformable.cpp(3): fatal error C1083: Cannot open include file: 'Quaternions.h': No such file or directory
I tried to comment out "#include Quaternions.h" in Transformable.cpp and it seems to work now.
« Last Edit: 2010-09-20 11:21:06 by ic07jb7 »

Offline MrAndersson

  • Full Member
  • ***
  • Posts: 142
Re: EDA221 - Introduction to 3D 2010 HT1
« Reply #11 on: 2010-09-20 11:21:18 »
Ah, this file should not be there at all... Search for all occurances of "#include "Quaternions.h"" and remove them, and it should work. I'll ask CJ to post a new zip without this problem.

Offline MathiasHaage

  • Newbie
  • *
  • Posts: 33
Re: EDA221 - Introduction to 3D 2010 HT1
« Reply #12 on: 2010-09-20 11:28:26 »
Hi,

To answer the question earlier:

vec3f evalLERP(vec3f &p0, vec3f &p1, const f32 t, const f32 x)

should be

vec3f evalLERP(vec3f &p0, vec3f &p1, const f32 x)


The parameter t stands for tension and is used in the Catmull-Rom function signature, it is not used for linear interpolation.


The interpolation function returns a vec3f in order to fit the transform methods, i.e. in the RC_update method you will write something like:

vec3f P0(0,0,0);

vec3f P1(1,0,0);

elapsedTime += Platform::getFrameTimeStep();

node->setTranslate( evalLERP(P0, P1, x(elapsedTime)) );

having x defined as a function of time (the function contents is up to you, acceleration, velocity, ...):

f32 x(f32 t) {

    // x as function of time with proper bounds for interpolation functions

    return t - floor(t);

}



The return value of the interpolation function is vec3f, not vec3f*. This is so you can write something like this in your implementation:

vec3f evalLERP(...) {

    vec3f Pinterpolated; // Allocate on stack

    // Your code

    return Pinterpolated; // return a copy of the result

}


Note that the interpolation functions are only dealing with a small interpolation interval (2 and 4 points respectively). You are required to interpolate between 10 points minimum. A suggestion for doing this is to organize your points in an array, then create an interpolation function having this array as input, the parameter x, and possibly a selector for which kind of interpolation you want. In this function, first use the parameter x to select which points to interpolate inbetween, then interpolate as the second step.
« Last Edit: 2010-09-23 08:57:43 by MathiasHaage »

Offline MrAndersson

  • Full Member
  • ***
  • Posts: 142
Re: EDA221 - Introduction to 3D 2010 HT1
« Reply #13 on: 2010-09-20 11:33:26 »
Quote
Hej,vi har en fråga angående interpolationsmetoderna i Interpolation.cpp som ska implementeras. Metoden för lineär interpolation definieras som:
vec3f evalLERP(vec3f &p0, vec3f &p1, const f32 t, const f32 x)
Och i handledningen beskrivs den lineära interpolationsmetoden (om man multiplicerar ihop matriserna) som:
p(x) = p0(1-x) + p1x, där 0<=x>=1 och p0 och p1 är punkter i rummet.
Frågor:
Vi förmodar att parametern t till funktionen är ett mått på antal punkter (upplösningen i interpolationen), är det korrekt?
Varför behövs paramtern x? Man vet ju att den ska variera från noll till ett.
Och varför returneras en 3vektor? Borde man inte returnera alla interpolationspunkter? eller är det (dx,dy,dz) som returneras? Eller ( {x}, {y}, {z} )?
Om du tycker att svaren på de här frågorna är till för mycket hjälp får du gärna hänvisa mig till litteratur som förklarar det. Vi har letat i boken, assignment.pdf, föreläsningsslidsen (behandlar 2dimensionell interpolation) samt internet utan större framgång. Tacksam för svar.

Jag kan försöka svara på detta, men CJ är mer kompetent i området.

evalLERP är nog där bara för att "få er i rätt stämning". Det är meningen att ni ska implementera er evalCatmullRom() med utgångspunkt från denna funktionen. Jag skulle tro att t syftar på tau (sid 17 i seminariet) som påverkar hur kurvan uppför sig (styvheten eller vad man ska kalla det). När ni anropar evalCatmullRom så gör det för ett visst x och får ut koordinater därefter. Ni evaluerar alltså inte hela kurvan med ett enda anrop till funktionen, utan endast en punkt. När rymdskeppet rör sig runt i scenen så anropar ni funktionen för ett visst x och får ut koordinater i World. Ni uppdaterar sedan x för nästa frame "x += delta" där delta är något lämpligt, tidsberoende hopp.


Offline e03mo

  • Newbie
  • *
  • Posts: 4
Re: EDA221 - Introduction to 3D 2010 HT1
« Reply #14 on: 2010-09-21 11:35:04 »
Hi,

To answer the question earlier:

vec3f evalLERP(vec3f &p0, vec3f &p1, const f32 t, const f32 x)

should be

vec3f evalLERP(vec3f &p0, vec3f &p1, const f32 x)


The parameter t stands for tension and is used in the Catmull-Rom function signature, it is not used for linear interpolation.


The interpolation function returns a vec3f in order to fit the transform methods, i.e. in the RC_update method you will write something like:

vec3f P0(0,0,0);

vec3f P1(1,0,0);

node->setTranslate( evalLERP(P0, P1, x(Platform::getFrameTimeStep())) );

having x defined as a function of time (the function contents is up to you, acceleration, velocity, ...):

f32 x(f32 t) {

    // x as function of time with proper bounds for interpolation functions

    return t - floor(t);

}



The return value of the interpolation function is vec3f, not vec3f*. This is so you can write something like this in your implementation:

vec3f evalLERP(...) {

    vec3f Pinterpolated; // Allocate on stack

    // Your code

    return Pinterpolated; // return a copy of the result

}


Note that the interpolation functions are only dealing with a small interpolation interval (2 and 4 points respectively). You are required to interpolate between 10 points minimum. A suggestion for doing this is to organize your points in an array, then create an interpolation function having this array as input, the parameter x, and possibly a selector for which kind of interpolation you want. In this function, first use the parameter x to select which points to interpolate inbetween, then interpolate as the second step.


What would the proper flow be, computing all the interpolation points in advance, hence in the RCInit method? Or should this be done from the RCUpdate method?

 

joke