Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 28 Apr 2007
Offline Last Active Today, 07:22 PM

#5269495 How to support multiple rendering paths in my engine?

Posted by HappyCoder on 05 January 2016 - 03:58 PM

You will need to make custom entry points for your shaders that take and return general data then have a deferred shader and a forward shader you compile with the other shaders in your code. This means you will compile each shader twice, once for forward shading, once for deferred shading.

General shader code
ShaderResult shaderMain()
  ShaderResult result;

  result.diffuse = ...;
  result.emmisive = ...;
  result.normal = ...;

  return result;

Forward Shading Code
void main()
  ShaderResult result = shaderMain();
  gl_FragColor = calculateLighting(result);
Deferred Shading Code
void main()
  ShaderResult result = shaderMain();
  gl_FragData[0] = result.diffuse;
  gl_FragData[1] = result.emmisive;
  gl_FragData[2] = result.normal;
Then in your deferred lighting pass
void main()
  ShaderResult lightingInput;
  lightingInput.diffuse = texture2D(diffuseTex, texCoord);
  lightingInput.emmisive = texture2D(emmisiveTex, texCoord);
  lightingInput.normal = texture2D(normalTex, texCoord);
  gl_FragColor = calculateLighting(lightingInput);
Then you need to have two different composite paths. You would choose which compiled shader to use for each object rendered depending on if you are using forward shading or deferred shading.

#5268522 Image Target Recognizer‏

Posted by HappyCoder on 30 December 2015 - 03:56 PM

EmguCV is a C# wrapper for OpenCV

#5268226 A funny way to handle Unique weapons

Posted by HappyCoder on 28 December 2015 - 03:04 PM

A game designer from Blizzard once shared this wisdom with me. Game ideas can usually be placed in three categories.

1. Ideas where the computer has fun
2. Ideas where the game designer has fun
3. Ideas where the player has fun

To clarify what I mean, an example of the computer having fun would be something like a complicated stats/combat system that has lots of interconnected computations that only the computer could understand.

I definitely like some of the elements of your game idea, but many aspects sound like it would be frustrating to the player and sound like you, the designer, are having fun. To me, it would feel very restrictive to have to play just to keep my weapon. Don't punish the player for having a life outside your game. People would make bots/hire others to keep their weapons. I feel like these rare weapons would fall to a small group of people who are very dedicated to the game and quickly become the dominant force in the game.

The idea of unique weapons is cool. I would just modify one aspect of it. Allow the player to hold onto any item indefinitely but only allow them a single unique item. If they find another unique item they like better then they must drop their other unique item before getting the new one. If two or more people want the dropped item then perhaps they could win it in a deathmatch. However, with an MMO you cannot expect everybody who wants the weapon to be online at the same time. So you would have to solve that problem.

#5268148 Split Vertex Data reflection problem

Posted by HappyCoder on 27 December 2015 - 04:35 PM

    glBufferData(GL_ARRAY_BUFFER, sizeof(cubeVertices), &cubeVertices, GL_STATIC_DRAW);
    glBufferData(GL_ARRAY_BUFFER, sizeof(cubeNormal), &cubeNormal, GL_STATIC_DRAW);

I suspect this is your problem. What this does is allocates the buffer to be big enough to store the vertices and copies them over then reallocates the buffer to fit the normals and only the normals then copies those over. You buffer is not big enough to store both the vertices and normals. I would change it to look like this

    glBufferData(GL_ARRAY_BUFFER, sizeof(cubeVertices) + sizeof(cubeNormal), NULL, GL_STATIC_DRAW);
I would also look into interlacing your vertices and normals rather than having them separate, but I would do that only after you get what you currently have working.

#5267560 How to finish a game

Posted by HappyCoder on 22 December 2015 - 05:11 PM

That usually happens to me when I try to make a game larger than what I can make. It is hard to cut back on ideas for you game but sometimes it has to be done. My advice is to simplify your game ideas or just accept your game will take a long time to complete.

Try doing a game jam. Set a restriction to make a simple game in a short time period. If all you have is a game or two to complete a game then you are sure to simplify a lot.

#5267040 How do you organize your time for game dev?

Posted by HappyCoder on 19 December 2015 - 11:06 AM

I usually work on either what i'm excited about doing that I feel will add value to the game or on what is blocking the game from progressing. I don't have a road map beforehand of what I will work on and when, I just kinda wing it. When doing this, be sure to play test your game early and often so you can gauge what needs work. Identify where players get stuck, when objectives aren't clear, what is frustrating, and fix those problems.

#5266592 Is this game idea possible?

Posted by HappyCoder on 15 December 2015 - 08:35 PM

What you are describing sounds like it would be in the millions of dollars to make. What you are suggesting sounds similar to skyrim, only a different setting. Skyrim had a budget of 80 million dollars. If you even want a shot at what you are describing you will either need lots of funding and experience or you will have to cut back on your vision.

Having highly polished realistic graphics is at odds with having a large world to explore. If you were willing to go with a simple, maybe even 2d, art style you can more quickly create a large world to explore since the art assets can be created faster. You definitely can have both good graphics and a large world, but it will cost you.

#5266589 Format for SSAO and Blur ?

Posted by HappyCoder on 15 December 2015 - 08:26 PM

My main concern is compatibility and speed, not so much memory usage.

When dealing with the GPU, memory is speed. Moving memory to and from the GPU can easily be a larger bottleneck than how much data you can crunch. You should also consider making your SSAO render target smaller than the screen resolution.

#5266569 Drive a car to a certain destination

Posted by HappyCoder on 15 December 2015 - 05:35 PM

However I think this might be overkill to do for lots of cars in my Android racing game.
I always try to avoid sin and cos because I was told they are very expensive to compute on CPU and I wanted to ask if there is a better faster easier way to calculate this?
Or if this is a good way to go.
Best Regards

Unit vectors are excellent at this kind of thing and the best part is that when used correctly don't have many sin/cos calls. Avoiding sin/cos is a good call but don't think you can't use it.

I was about to post a solution of rotating a vector towards another without the need of any sin/cos but then I decided against it since it would be untested code. Let me know if you want to see it but know what you want can be done without sin/cos.

#5266513 University Masters Project

Posted by HappyCoder on 15 December 2015 - 11:59 AM

It looks good visually, the sense of exploration feels good.

A few points of feedback.
The music doesn't seem to fit.
The buckets of water look like decoration so I probably would not have tried to pick them up.
It also isn't clear that the flames can be put out. To me they look like barriers meant to keep the player from leaving the intended play area.
The pulsing flame spouts have no visual indication where they are. It would be frustrating to be killed by one you didn't know was there.

Impressive work though, it is easy to see the work you have put into it so far. Gamedev is not easy.

#5266296 Quaternion To Euler issue, fix possible ?

Posted by HappyCoder on 14 December 2015 - 11:23 AM

When you changed this
1.0f - 2.0f * y * y - 2.0f * zz
to this
1.0f - 2.0f * ( ( y * y ) - zz )
You didn't factor out the -2.0f correctly to give you what should be this

1.0f - 2.0f * ( ( y * y ) + zz )
Same applies to the assignment of *X

#5265962 Grid, Quadtree or something else?

Posted by HappyCoder on 11 December 2015 - 06:05 PM

First of all, make sure that it is the collision that is dragging down the framerate and not the rendering. Do all of the 500 objects each trigger a separate draw call?

As for the quad tree, one implementation I have seen treats all nodes as leaf nodes. To insert an object into a node you first get the object's bounding box.
def insertIntoNode(node, object):
  foundChild = False
  for child in node.children:
    if child.boundingBox.contains(object.boundingBox):
      insertIntoNode(child, object)
      foundChild = True

  if not foundChild:
    object.currentIndexNode = node
Then to update an object
def updateObject(node, object):

  if not node.boundingBox.contains(object.boundingBox) && node.parent:
    updateObject(node.parent, object)
    foundChild = False

    for child in node.children:
      if (child.boundingBox.contains(object.boundingBox)):
        updateObject(child, object)
        foundChild = True
    if not foundChild:
      if object.currentIndexNode != node:
        object.currentIndexNode  = node
The tradeoff is you don't have to insert one object into many nodes but it does increase the number of objects to check around node boundaries. The worst case is all the objects are in the center of the spacial index since all the objects would be in the same spacial node.

Also note the psuedo code I gave above doesn't handle splitting nodes when they get to full or combining them if the children empty out.

#5265350 Signed Rotation

Posted by HappyCoder on 07 December 2015 - 04:38 PM

Wouldn't the type conversion mess up the data at all?  For example, suppose I had a negative number, and when I convert it into a uint, it will become 0, won't it?
Well let's say I have my reasons but frankly they're hard to explain, with a whole lot of technical junk and honestly I'm in a hurry, but thanks.

Casting between signed and unsigned just changes the interpretation of the underlying data, no actualy changes to the data happens. Signed numbers use 2s complement so negative numbers in signed turn into a large positive number which depends on how many bits are in the number.

EDIT: Alvaro beat me to it

#5265344 Off Center Projection ?

Posted by HappyCoder on 07 December 2015 - 04:09 PM

Yup, you just apply translation and scaling transformations after the perspective transform

finalPerspectiveMatrix = Translate(offsetX, 0, 0) * perspectiveMatrix

one thing to note, the view space after the perspective transform is in the range form -1 to 1 in the x direction, so offset would likely be a value in that range. If you need to zoom in after translating you can apply scale transformation after the perspective transform

#5265303 Quaternion Skinning

Posted by HappyCoder on 07 December 2015 - 12:24 PM

You need to rotate the child's local position by the parent's world rotation before adding it to its parent's world position to get the child's world position