Jump to content

  • Log In with Google      Sign In   
  • Create Account

HappyCoder

Member Since 28 Apr 2007
Offline Last Active Yesterday, 04:44 PM

#5272865 Multi UV in WebGl

Posted by HappyCoder on 27 January 2016 - 01:26 PM

WebGL has no connection to any file format. So you have complete freedom on what data you load and how you display it. Multiple UV is pretty straight forward with WebGL. You simply bind another attribute to your shader but you will need to load a file that supports multiple UVs when storing the mesh. Obj does not support multiple UVs. DAE is a good format. It is widely supported, easy to parse, and supports multiple UVs.


#5272742 Need help with basic frustum culling

Posted by HappyCoder on 26 January 2016 - 11:46 AM

Put 1 for the w component before the multiply, then divide the resulting vector by the w value after the multiply

// first you find the clipping space matrix
clippingSpacePoint = MVP_matrix * vec4(x, y, z, 1)
// then you normalize the point by dividing by w
clippingSpacePoint.x /= w
clippingSpacePoint.y /= w
clippingSpacePoint.z /= w
// now any point that is on screnn will have a clippingSpacePoint x and y coordinate between -1 and 1
To do this accurately you will need to transform 4 corners of the tile and determine if any point lies inside the -1 to 1 range. You will also need to determine if a tile edge intersect the frustrum. It is possible for a tile edge to be on screen with none of the corners on screen.


#5271307 Understanding cross product without delving too much on Linear algebra

Posted by HappyCoder on 15 January 2016 - 11:33 AM

Given a plane, pick two unique points that lie on the plane. Imagine a vector that starts at one point and points towards the other. That is what the author means by a vector parallel to the surface of the plane. A triangle has three unique points on a plane. So staring at one of the points on the triangle and creating a vector towards each of the remaining two points gives two unique vectors that are each parallel to the plane. Doing the cross product on these two vectors results in a vector perpendicular to the plane. You could pick any three points on the plane, it is just convenient that a triangle comes with exactly what you need.


#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.
 
Thanks
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
      break

  if not foundChild:
    node.objects.add(object)
    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)
  else:
    foundChild = False

    for child in node.children:
      if (child.boundingBox.contains(object.boundingBox)):
        updateObject(child, object)
        foundChild = True
        break
    
    if not foundChild:
      if object.currentIndexNode != node:
        node.objects.add(object)
        object.currentIndexNode.objects.remove(object)
        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.




PARTNERS