• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

156 Neutral

About JimmyDeemo

  • Rank
  1. Newbie

    [quote name='NSH6' timestamp='1305879135' post='4813382'] So, while I'm currently learning some C++ (from what I have observed is the industry standard), I was thinking of eventually looking into shader development. My first question is, when developers use graphics software such as 3ds Max or Softimage, can they create their own custom shaders to achieve a desired visual effect? And are shaders developed with GLSL/Cg/Direct3D? [/quote] Firstly i think there is a little confusion here as to what shaders are and how they are used. I believe in general that shaders aren't something done by artists who use modelling software to produce models. They are essentially mathematical computations that get applied at different points in the rendering stage to give certain effects. [url="http://www.arcsynthesis.org/gltut/Basics/Intro%20Graphics%20and%20Rendering.html"]Check out this page[/url] for a brief description of rendering basics, it finishes up by talking about shaders. [quote name='NSH6' timestamp='1305879135' post='4813382'] My second question is, are there limits to what kinds of games people can make using pre-existing engines such as Unity or Unreal? [/quote] This has a couple of meanings too. What do you mean by 'limits'? In general there are no limits to the game play aspects that people think up, just different ways of implementing them. If you are talking about limits in terms of pushing graphical processing and effects then you are limited by the engine you use. Unreal engine its probably one of those that are at the fore front of pushing what's possible, just look at some videos of the latest version. [quote name='NSH6' timestamp='1305879135' post='4813382'] I apologize if I'm getting ahead of myself, I'm just lost as to where I should start, because many people seem to agree that the best way to get into game development is to start small, and build your way up. Assuming I manage to progress in my studies of C++, where would I go from there? [/quote] You seems to have the right attitude towards where you want to be. Remember that if you want to be a Game Programmer using C++ then you first need to be a regular programmer using C++. Having a greater understanding of the ins and outs of your chosen language is a great benefit, and doesn't mean that you can't put a game twist on things. The point is not to overwhelm yourself, because when i do that i get disinterested.
  2. External forces and RK4

    [quote name='johnstanp' timestamp='1305833799' post='4813152'] Yes, you accumulate the forces before the update and keep the accumulator constant for the RK4 integrator (update function). The state of the rigid body is constant untill you assign the result of the integration step to it i.e untill this->state_ = u_state; But no, the momentum is not the same...Since x1 != x2 and x2 != x3 and x3 != x4 if forceAcc_ != 0. Do the computing yourself, I mean by hand, that'll be a lot more clear. This is how I understood it. Take a pen, a paper and a calculator and do it by hand. I could have used a function that computes the force for a given state of the rigid body and an instant (time), meaning that I would have known beforehand the forces that would have acted upon the body, but you would have been distracted by the details of the implementation (the use of a function pointer or a functor). If you understand this first part, then I will post a version where the force actually varies during t and t+dt. But you have to understand that unless the forces acting upon the body are known beforehand, you are the only person to actually decide how they will vary between two updates. That'll be clearer after but for now, do the previous computations with a pen and a paper. [/quote] Apologies, what i meant was 'In each derivative calculation, the momentum is just the same as the forces, because time isn't taken into account.'. I will take some time an do as you suggested. The slight hurdle i have got to get over is that your method looks a little different to mine (and the articles i followed), but i am sure its all there. Once i get my head around it i will post again.
  3. External forces and RK4

    [quote name='johnstanp' timestamp='1305822367' post='4813056'] I haven't taken a lookt at your code: it is not necessary, since I'll give a general answer. You can consider that the total force applied to the rigid body is constant between t and t+dt: this is what I do for my update function using RK4. [/quote] Thanks for your reply, as well as the code but i am afraid i find you answer quite cryptic. So let me just see if i am on the right track here. What you are saying is that for a given state of a Rigid body object, forces would be accumulated in the cycle (e.g. +thrust, -drag, etc.), when it comes to each of the four derivatives it can be considered that the forces are the same and are not influenced by the time. Is that right? So therefore the momentum is just the same as the total forces acting on the object. If i have understood that right, then that's great and I'm pretty sure i can sort my code for that. But i just wondered why this was the case?
  4. External forces and RK4

    So i started this [url="http://www.gamedev.net/topic/597235-getting-my-head-around-rk4/"]thread[/url] a while ago, and the replies dried up. I don't think i made it clear as to my problem so i wanted to re word it so that i might get some more responses. Firstly let me point out that i know RK4 is over kill, but it's mainly just so that i can learn and practise my coding techniques, so while i understand there are good intentions to pointing out other systems lets try and keep this about RK4. So i have implemented a system similar to that detailed on [url="http://gafferongames.com/"]http://gafferongames.com[/url] but i am still confused as to where external forces fit into the system. From my understanding the way RK4 works is that it needs to calculate the force of a derivative implicitly from the current state, rather than explicitly applying forces once per update. So if that's the case how do i say apply some thrust to a ship for example? Let me break it down furthur i have the position and momentum of the RigidBody prior to any calculation, i also have the velocity of the current derivative step. What i want to be able to do at this point is apply things like collision input and 'push' forces, and the end result should be to calculate the forces for this current derivative step. I also have the current time step also. Here is some code for you, hopefully its clear enough, please just ask if anything is confusing. [code] /** * Integrate a state forward by a delta time. * * This function uses the RK4 integration method to update the state by a given * time. * * @param state Reference to the state that needs integrating. * @param deltaTime Time to move the state on by. */ void CPhysController::Integrate(CRidgidBody::CRBState &state, float deltaTime) { //RK4 uses 4 derivatives of the current state at different points within the delttime. //Each evaluation uses the previous derivative to calculate next. CRidgidBody::CRBDerivative a = Evaluate(state, deltaTime, CRidgidBody::CRBDerivative() ); CRidgidBody::CRBDerivative b = Evaluate(state, deltaTime*0.5f, a); CRidgidBody::CRBDerivative c = Evaluate(state, deltaTime*0.5f, b); CRidgidBody::CRBDerivative d = Evaluate(state, deltaTime, c); //Using a wighted sum that comes from the Taylor Series expansion, the best overall derivative //is calculated. This can then increment the state. state.UpdatePosition( 1.0f/6.0f * deltaTime * (a.mVelocity + 2.0f*(b.mVelocity + c.mVelocity) + d.mVelocity) ); state.UpdateMomentum( 1.0f/6.0f * deltaTime * (a.mForce + 2.0f*(b.mForce + c.mForce) + d.mForce) ); } CRidgidBody::CRBDerivative CPhysController::Evaluate(CRidgidBody::CRBState &state, float deltaTime, const CRidgidBody::CRBDerivative &prevDerivative) { //First move the state on base on this time step value, using euler integration. state.UpdatePosition( prevDerivative.mVelocity * deltaTime ); state.UpdateMomentum( prevDerivative.mForce * deltaTime ); //Prep our derivative CRidgidBody::CRBDerivative derivative = CRidgidBody::CRBDerivative(); derivative.mVelocity = state.GetVelocity(); Resolve(state, derivative); return derivative; } void CPhysController::Resolve(CRidgidBody::CRBState &currentState, CRidgidBody::CRBDerivative &derivative) { //??? } [/code] Any help understanding this would be great. I did think that perhaps i should be coming at the problem from a different angle, perhaps someone here could enlighten me.
  5. Getting my head around RK4

    Hi all, I've not actually had chance to come back to this since my last post, but will do soon. @cannonicus Thanks for you detailed post. I'm not sure that you understood where my confusion comes from. I am quite happy with how the integrator works, and its ins an outs. I am confused about applying forces to an object so i can actually make use of it. Perhaps it might be best to deal with this by example. I have an object that i want gravity to act upon. When using Euler integration i would apply this force each update, solve and then integrate to give me the new position of the object. Where does this application of force fit within the RK4 integrator? I have to put it all in one function right? The equivalent of [size="2"][color="#1C2837"]Glenn Fiedler's static void forces() function. Is it simply a case of storing external influences on an object and then solving them in each evaluation step?[/color][/size]
  6. Getting my head around RK4

    Anyone have any idea about this? Perhaps i am not explaining myself very well? Let me know if more info would help.
  7. Getting my head around RK4

    [quote name='wildbunny' timestamp='1299680740' post='4783556'] I just wanted to check - is there any particular reason you're using RK4? [/quote] In all honesty, its simply as a learning experience, i don't intend my little game to be particularly physics heavy at all. The code i am writing is mainly for portfolio/demo purposes and i though i would push the boat out a bit. In addition i am creating my own little library of stuff so i figured i'd write it as reusable. After reading the articles on Glenn's blog it seemed that implementing an RK4 integrator might not be much more work anyway. I have done [color=#1C2837][size=2]euler before, but am i so far off the mark with this that i am best to stick with it?[/size][/color] [size="2"][color="#1C2837"] [/color][/size] [color="#1C2837"][size="2"]I also know it might be a good idea to simply use an existing framework, but as i said its for learning and Glenn's blog provided what seemed like a good explanation. In particular the rotation aspect of it, as this was something that confused me even in euler integration.[/size] [/color]
  8. Getting my head around RK4

    So i want to add some physics to my little demo game, and after reading Glenn Fiedler's blog [url="http://gafferongames.com/game-physics/"]here[/url], i decided to try and implement an RK4 integrator. So i generally understand how RK4 work, how you get the derivatives from the current object state, applying forces at different points in the time step. Then you move on the simulation based on some kind of weighted average of those 4 derivatives. My problem is understanding how external influences are applied to an object in the system, as Glenn Fiedler's example seems to be dependant on time rather on an object moving under the influence of external forces. Let me give you an example, here is a function and description from the source code in Glenn's article titled 'Physics in 3D': [code] /// Evaluate derivative values for the physics state at future time t+dt /// using the specified set of derivatives to advance dt seconds from the /// specified physics state. static Derivative evaluate(State state, float t, float dt, const Derivative &derivative) { state.position += derivative.velocity * dt; state.momentum += derivative.force * dt; state.orientation += derivative.spin * dt; state.angularMomentum += derivative.torque * dt; state.recalculate(); Derivative output; output.velocity = state.velocity; output.spin = state.spin; forces(state, t+dt, output.force, output.torque); return output; } /// Calculate force and torque for physics state at time t. /// Due to the way that the RK4 integrator works we need to calculate /// force implicitly from state rather than explictly applying forces /// to the rigid body once per update. This is because the RK4 achieves /// its accuracy by detecting curvature in derivative values over the /// timestep so we need our force values to supply the curvature. static void forces(const State &state, float t, Vector &force, Vector &torque) { // attract towards origin force = -10 * state.position; // sine force to add some randomness to the motion force.x += 10 * Mathematics::sin(t*0.9f + 0.5f); force.y += 11 * Mathematics::sin(t*0.5f + 0.4f); force.z += 12 * Mathematics::sin(t*0.7f + 0.9f); // sine torque to get some spinning action torque.x = 1.0f * Mathematics::sin(t*0.9f + 0.5f); torque.y = 1.1f * Mathematics::sin(t*0.5f + 0.4f); torque.z = 1.2f * Mathematics::sin(t*0.7f + 0.9f); // damping torque so we dont spin too fast torque -= 0.2f * state.angularVelocity; }[/code] From what i can gather 't is the time since the start of the simulation. In this function he uses the time to give a cube object motion. So firstly i want to ask, is this an integral part of the RK4 implementation? Does the force calculation of a derivative need to be derived from a total time value? What i want to know is how do you use this model in a simple example such as gravity and say a ships thrusters acting against it? My thought is that forces acting on an object would be stored as a variable in the State class, so you would add gravity as a force acting down each update, and the thrusters added to this store acting in the opposite direction on each update the thrusters are active. The forces function would then be modified to be interested in the time step rather than the total time. Giving you something that looks like this: [code]static void forces(const State &state, float dt, Vector &force, Vector &torque) { //Force of derivative is equal to the external forces over the time step. force = state.totalExternalForce * dt; //...omited the rotation for clarity... }[/code] Am i on the right lines here? Have i misunderstood something fundamental? Thanks for reading my gibberings, any help understanding this would be much appreciated.
  9. OpenGL Calculations on the CPU or the GPU?

    Ahh i see. Ok thanks a lot for the comments guys. Much appreciated.
  10. OpenGL Calculations on the CPU or the GPU?

    [quote name='Nanoha' timestamp='1298968369' post='4780479'] I'd stick to what your currently doing. [/quote] Phew that's good to know. I see what you mean about the matrices, it does seems like it would be expensive to do it like that. However, bearing in mind what you said would it be more efficient to calculate the model matrix in the vertex shader? This is constantly changing, unlike (in my case) the projection and view matrices. I suppose this is really an optimisation question isn't it as both methods have the same output; optimisation it probably overkill in my situation as I'm producing a small demo and nothing that complicated.
  11. So i have been putting together a little game as a (re)learning experience. This time round i have been using OpenGL3 and shaders and there are a few things i'm confused about regarding calculations performed in regular code and those in the shader. So with that in mind, can anyone give me a hand understanding the following questions. 1. Right now my simple shader looks like this: [code] #version 330 uniform mat4 projectionMatrix; uniform mat4 viewMatrix; uniform mat4 modelMatrix; layout (location = 0) in vec4 in_Position; layout (location = 1) in vec4 in_Color; smooth out vec4 pass_Color; void main(void) { gl_Position = projectionMatrix * viewMatrix * modelMatrix * in_Position; pass_Color = in_Color; } [/code] So i set my projection, view and model matrix in my main code and simply multiply them in the shader, is that right? Should i be passing more 'raw' data to the GPU and calculating the matrices there? 2. Right now in order to translate and rotate my models (just a cube right now), I use the model matrix. I start with an identity matrix and then apply each transform to it before passing the matrix to the shader (see above). Is that the right idea or should i be using the model matrix for something else AND applying my transformations via another matrix. Any pointers on this would be much appreciated, thanks in advance.
  12. OpenGL Why doesn't OpenGL like this?

    [quote name='V-man' timestamp='1297351747' post='4772394'] As for the problem, check to make sure there is a GL context when you make GL function calls. If you are on Windows, I recommend GLIntercept which is a very nice tool. [url="http://www.opengl.org/wiki/Debugging_Tools"]http://www.opengl.or...Debugging_Tools[/url] [/quote] Its not a big deal right now, as using pointers to memory I've created myself doesn't seem to be a problem. Will check out those debugging tools though. Cheers for the link.
  13. OpenGL Why doesn't OpenGL like this?

    [quote name='FXACE' timestamp='1297350613' post='4772383'] No, I mean this function: [code]PFNGLUSEPROGRAMOBJECTARBPROC glBindProgramARB; glBindProgram(mShader->GetProgram());[/code] [/quote] Hmmmm well i can't find it in the [font=Arial, Lucida, sans-serif][size=2][url="http://www.opengl.org/sdk/docs/man3/"]OpenGL 3.3 Reference Pages[/url] which would suggest it has been depreciated? I'd rather not use depreciated functions if i can. Doesn't it seem strange you would need to bind the program when [/size][/font][size="2"][color="#1C2837"]GetUniformLocation takes the same parameter?[/color][/size]
  14. OpenGL Why doesn't OpenGL like this?

    [quote name='V-man' timestamp='1297343206' post='4772330'] Actually, he gave you false info. [/quote] Hmmm yes i thought so, see my edit above. Its a strange one to me as i can't see the difference as far as OpenGL is concerned, surely it just wants the value to look up the program. I am hoping using a vector of pointers (boost::ptr_vector) will work when i want to have more shaders. Or perhaps having a manger of this kind is the wrong approach?
  15. OpenGL Why doesn't OpenGL like this?

    [quote name='FXACE' timestamp='1297340974' post='4772322'] You need to bind the GL program before setting up uniform values...[/quote] Interesting, well the code i gave at the start (using new) works without doing the bind you suggested. How is that possible? Just sheer luck in the order of execution? I searched my project and i don't bind the program anywhere, just pass its 'GLuint' value around. Edit: Cheers for the reply but i'm afraid this doesn't work, i switched my manager back to the old way (i.e. not using 'new) and the program errors again. So i tried your suggestion like this; [spoiler] [code] CShaderManager::AddShader(0, "assets/shaders/shader.vert", "assets/shaders/shader.frag"); mShader = CShaderManager::GetShader(0); glBindProgramARB(GL_VERTEX_PROGRAM_ARB, mShader->GetProgram() ); mProjMatrixLocation = glGetUniformLocation(mShader->GetProgram(), "projectionMatrix"); Utils::CheckGLError(); glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0); [/code] [/spoiler] But this has the same error. Did you suggest the correct function as you didn't specify that it had additional arguments like it requires? I can't find it in the OpenGL 3.3 reference, i suppose i should have mentioned I'm on 3.3.
  • Advertisement