Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 26 Feb 2009
Offline Last Active Today, 01:06 AM

#5294271 Stencil Shadows Problem

Posted by Nanoha on Today, 01:05 AM

I'm no expert on this but I did shadow volumes recently and didn't have an issue with shadow volumes going through themselves. I was shadowing a Menger Sponge fractal. I used the following tutorial, perhaps there is something in it that might help:



The major problem I hit was making sure the quads were facing the correct way. You said you checked this but did you check it on the actual mesh that is giving you problems? I assume you rendered back faces one color and front faces another to see? Do you have front/end caps? I also found I needed to use a 'sealed' mesh, is there a split around that quad that is causing you problems?

#5293514 Do you usually prefix your classes with the letter 'C' or something e...

Posted by Nanoha on 26 May 2016 - 01:09 AM

I don't prefix classes. I can't say it doesn't help since I don't do it to know but I don't feel like I'm hindered from lack of doing it. 

#5292925 Confused About Frames Per Second

Posted by Nanoha on 22 May 2016 - 02:34 PM


I honestly am not totally understanding the logic of that code.  I would instead just use the deltaTime and do a formula to get the FPS than to actually count frames.  It should just be a simple division.  You need to get the deltaTime in either seconds(likely 0.xxxx) or in miliseconds.  Then use either 1 second or 1000 milliseconds and divide by the deltaTime.  That gives you how many "deltaTime" there is in a second, which happends to be frames per second.  Now, you may want to add on some "smoothing" and/or averaging things out, but that gets you started.


Also, I would pay attention, maybe more attention, to the deltaTime itself.  Some people find it easier to understand the numbers with that, because it is directly saying how many MS the frames are taking, so it is more direct.


Thanks, this is good advice, however I don't think it really clears up my confusion. Even after making this change I'm still getting the same results. My deltaTimes are typically ~.001 seconds so when I divide 1.0 by ~.001 I'm still getting around 1000 FPS. Why is this so far off from the 60FPS I hear is the norm, and why, when it drops to anything lower than 400FPS, is it drastically lagging?



1,000 fps isn't unusual, don't think you have done it wrong just because you are getting significantly more fps than 60. If you have AAA quality graphics going on and you are getting 1,000 fps then chances are you are doing something wrong but if your scene is very basic then you will probably have high fps.


This bit looks odd:

// Count the number of frames displayed each second.
if (fpsTimeCount_ > 1.0f) 
	fps_ = fpsFrameCount_;
	fpsFrameCount_ = 0;
	fpsTimeCount_ = 0.0f;

What happens if for one frame deltaTime is 5 seconds? that would make fpsTimecount >5 and suddenly your fps is showing as 5 times or more than it actually is. Just make sure you account for that extra time:

fps_ = fpsFrameCount_ / fpsTimeCount_;

It's all in the name, frames(fpsFrameCount_) per(/) second(fpsTimeCount_).

#5292246 Almost finished game - needs fresh eyes

Posted by Nanoha on 18 May 2016 - 04:36 AM

I like that distortion effects you have going on. I think the screen shake needs to be toned down a little. At the start of the video the screens hake is fine but towards the end when the enemy ship is blown up it's quite extreme.

#5291822 Best gaming platform in the future with marketing perspective.

Posted by Nanoha on 16 May 2016 - 06:16 AM

Personally I am very much thinking of making something for VR. I have a Vive and think it is awesome. Right now it seems people are snapping up anything and everything and competition is low. I expect that to change by the time I actually have anything worth selling (if ever..) but right now it looks like a good direction and it's certainly very interesting. There are already a few holes in the available games that could be filled by a small team with a low budget. The other hole is of course AAA story driven games.


As Alberth points out, 15 years is a long time but I'm sure it'll involve a lot of VR. Personally I would go with what interests you.

#5290880 My game ends up being boring

Posted by Nanoha on 09 May 2016 - 03:04 PM

Thanks for the answer. 


Who says it boring? Im saying that...any the low download numbers :-)


Again, this helped me a lot.




Low download numbers don't necessarily mean it's boring, it's just undiscovered. It'll probably take quite some time before someone takes the time to comment on your game and confirm if it's boring or not.

#5290832 My game ends up being boring

Posted by Nanoha on 09 May 2016 - 11:06 AM

Just from looking at the images I would say ZigZag looks more interesting than yours. Perhaps it's the car, I have nothing to back this up but I would guess that limits the audience too (though that wouldn't necessarily make your game boring) where as the style of ZigZag looks to have more general appeal. The collecting diamonds looks like it helps too. Perhaps you have distilled it too much.


Who says it's boring? You, friends? I think it's quite hard to say why some of these games become insanely popular and others don't. Expectations influence our future experiences and looking at ZigZag's screenshots they do look more appealing (and thus I would expect to enjoy it more) than your screenshots.


Why not make it look more fun? Maybe make it look like a toy card on a cartoonish track. Maybe have a pursuer (police car) which is constantly gaining on your car and have simple speed boosts scattered around that driving over helps you maintain your lead. Hopefully that would add a little excitement.

#5290280 What does the "Most Constrained" heuristic mean?

Posted by Nanoha on 05 May 2016 - 12:08 PM

The world is always in a 'state', you perform actions on a 'state' for example opening a door and that changes the world to a new state - the world with an open door. To get from one state to a more different state for example, the state of a world without a cup of tea to the state of the world with a cup of tea requires many transitions - boil kettle, put tea bag in cup etc etc.


Imagine there was a finite number of world states, from each state you have a number of actions you can perform. A state where the door is closed you can choose to perform the action of opening a door. Similarly in a state where the door is open you can choose 'close door'. Some actions might be quite common and available in many of the world states - opening/closing a door might be quite common but other actions might be very rare.


In the example given, imagine there are 100 possible world states and being able to shoot that force-field armoured enemy with that laser rifle is only possible in 1 out of those 100 states then that is quite rare. Shooting some other enemy might be 20 out of every 100 states.


Your world might be in a state and you have the following actions:

Shoot generic enemy (20/100)

Shoot force-field armored enemy with laser rifle (1/100)


The suggestion is that you should choose the rarest action, to take advantage of it while it is available. That's what they mean by 'Most contrained' - the action that has the pre conditions/is the rarest. It's certainly not the only choice and I see it is only one of the heuristics they suggest.


It might be worth reading a bit more about world states.

#5287356 Memory Allocation

Posted by Nanoha on 17 April 2016 - 03:56 PM

Is IsEmpty() working correctly?

Are objects created with malloc?

is headNode a valid value?

Are the Nodes initialized to sensible values?


Check all everything is initialised to a sensible value (probably NULL). 

#5286989 What physics mechanism do you apply for double-jumps?

Posted by Nanoha on 15 April 2016 - 01:16 AM

I wouldn't worry about physical accuracy but just go for something that feels right. I like the sound of option 1 as I feel that rewards timing/player skill. I would have the second jump override the first jump as if it started from stationary as that would also give the player more control. The only real option is to try all 3 and see how they feel or find a game with a double jump mechanic that you like and try to imitate it.

#5286986 How to scale a model in OpenGL?

Posted by Nanoha on 15 April 2016 - 01:06 AM

It might be wise you learning newer opengl than doing this where glScale no-longer exists (I think OpenGL 3.2 onwards). I personally find it more intuitive (and you might do since you said you know the theory behind it).


If dpadam's suggestion doesn't work (it should) try this before it:


You probably already have it somewhere so you might not need it.


Are you able to see what you are renderign when you comment out the scale line?

#5286340 how to find x,y,z of a point in a sphere if I'm in the center of a sphere?

Posted by Nanoha on 11 April 2016 - 12:34 PM

Ok, I got to that pitch*yaw matrix ( or yaw*pitch, I got your result with yaw*pitch . And I multiplied by "forward" and it really works. But now another question comes, maybe I'm just tired, but why multiplying this by my original forward or backwards or +x or -x works, but if I multiply the matrix by my original "y", it doesn't work?


What do you mean 'doesn't work'? It will work with forward because it is designed to work that way but if you start throwing random vectors in it's no longer guaranteed to work because what you ask of it doesn't necessarily make sense so it depends what you are asking it to do. I assume you are not but you can't just put in 'up' as your original vector and then stick that in as your camera direction, depending on the angle it might not make sense. You sometimes lose a degree of freedom with rotations too (depending on how you rotate) so something along those lines might be coming in to play too.


Think about what happens in you look up 90 degrees, now if you yaw you are still looking up. You then put that in your camera (0, 1, 0) and also you put 'up' as being (0, 1, 0) which doesn't make sense in the lookat matrix (I don't think you can use two parallel vectors). The way to solve that is to have both a forward vector and an up vector that gets rotated rather than just the forward vector.


I can't really say for sure without know what effect it has.

#5286325 how to find x,y,z of a point in a sphere if I'm in the center of a sphere?

Posted by Nanoha on 11 April 2016 - 11:17 AM

I didn't formulate my question well, that's why you misunderstood me. The code I posted is actually working, but I don't quite understand all the logic behind it, but it is working, but I don't know why. And your code is working too, I'm sure, but why and how? :wacko: ( but thanks for the answer, anyways ).

There's a few things to consider with this, first there's the theory of it, then there's the maths of it and finally the implementation of it. I like to work things like this out by sticking my arm out in front of me (I call this forward(0,0, 1) but in OpenGL it would be (0, 0, -1)) and that is my look direction by default. I pretend I am in a huge sphere where my fingertips will always touch the inner surface. I think the second method I posted is easier so I'll do that. First it's doing pitch so I just rotate my arm up or down by verticalAngle, then it does yaw so I'd rotate on my chair horizontalAngle and my arm should then be pointing in the desired direction. That's the theory.

Mathematically I am just doing x-axis rotation of verticalAngle followed by y-axis rotation of horizontalAngle.

You just implement that in whatever way you choose. The code you have is doing the same thing - it is using a direction of (0, 0, 1) as forward. I don't know how they derived this but it goes like this:
x-axis rotation matrix (pitching) where V is vertical angle

1 	0 	0
0 	cos(V) 	-sin(V) 
0 	sin(V) 	cos(V) 

y-axis rotation matrix (yawing) where H is horizontal angle

cos(H)	0	sin(H)
0	1	0
-sin(H)	0	cos(H) 

You multiply those matrices to get a single matrix that does pitch followed my yaw and you get:

cos(H)	sin(V)*sin(H)	cos(V)*sin(H)
0	cos(V)		-sin(V) 
-sin(H)	sin(V)*cos(H)	cos(V)*cos(H) 

Then your original forward is (0, 0, 1) so as a matrix that is


Multiply that by the final matrix and you get:


You may recognise those terms from the code you have:

glm::vec3 direction(
cos(verticalAngle) * sin(horizontalAngle),
cos(verticalAngle) * cos(horizontalAngle)

Whether they got it the same way as I did I can't say but it does show that this is the exact same way just done far quicker than multiplying matrices (which is good).

#5286306 how to find x,y,z of a point in a sphere if I'm in the center of a sphere?

Posted by Nanoha on 11 April 2016 - 09:26 AM

I will assume 'up' is y. First you do yaw as you have done, so you rotate about the y-axis. Next you want to do pitch but instead of rotating about the x-axis as you think you might you first need to rotate the x-axis about the y-axis and then rotate about the new axis if that make sense.


Do you have access to quaternions? I will use those but it's basically the same method when using matrices (just more expensive).

// How you decide to turn mouse movement into an angle is up to you, you can do your sensitivity stuff here
// but for simplicity sake I will assume it's already done
float yawAngle = ...
float pitchAngle = ...

// Do yaw first though order isn't too important
Quaternion yaw = Quaterion::FromAxisAngle(Vector::UP, yawAngle);
// Now you can't just rotate about 'Right' to do pitch, you need a new Vector to rotate about
Vector newAxis = yaw*Vector::RIGHT;
Quaternion pitch = Quaternion::FromAxisAngle(newAxis, pitchAngle);
Quaternion final = pitch*yaw;
Vector direction = final*Vector::FORWARD;

That should work. The important part to note is finding the second axis to rotate about. glm should have some similar functions for creating axis-angle matrices if you need those, it should work the same way (it's just a lot more work for the computer that way).


you could possibly do pitch first too which does seem neater:

float yawAngle = ...
float pitchAngle = ...

Quaternion pitch = Quaterion::FromAxisAngle(Vector::RIGHT, pitchAngle);
Quaternion yaw = Quaternion::FromAxisAngle(Vector::UP, yawAngle );
Quaternion final = yaw*pitch;
Vector direction = final*Vector::FORWARD;

#5285757 Should getters and setters be avoided?

Posted by Nanoha on 08 April 2016 - 03:51 AM

He also implies in his webinar that all objects should be immutable. This idea sounds crazy to me, he is actually proposing to pass a new object every time we want to mutate it.
public Balance withdraw(double amount)
  return new Balance(balance - amount);


Ouch, that's an interesting idea but surely that is just asking for trouble.