Jump to content

  • Log In with Google      Sign In   
  • Create Account


WarAmp

Member Since 06 Sep 2000
Offline Last Active Jul 10 2014 12:26 PM
-----

#5142057 SNES Like 5 Layer 320x240 Graphics Library

Posted by WarAmp on 25 March 2014 - 12:45 PM

The problem is that we DON'T understand what you wrote. Is this something you made? Is this just something you found and thought was cool and wanted to share?

What's the purpose? Is it supposed to be a SNES emulator running on the GPU? Etc?




#5122463 How did 2D games handle this collision in antiquity?

Posted by WarAmp on 09 January 2014 - 05:25 PM

Well, you could have the collision shape actually just be half the width of the sprite, but "slide" based on the direction the sprite is moving.

 

ie: For ground collisions, the collision shape is width/2, but one side is always at the center of the sprite, and the other side is opposite the direction of motion.

If no ground collision is detected, expand the shape to full width and test again, this way you can still handle edge cases when jumping/falling properly.

 

Does that sound like it should work?




#5113137 Digits of Pi

Posted by WarAmp on 29 November 2013 - 07:05 PM


The initial assumption is that you have arrived at the last chamber, and there is a 50% chance that the referee has put in a bullet.
 
If there is a bullet, the bullet must be in this last chamber (there is no other way!), and the referee made his decision whether or not to put one in before anyone touched a trigger. The 50% chance that there is a bullet in one chamber doesn't change after the referee has tossed his coin, merely because nobody has died during the first five rounds. The only thing that changes during the game is the number of chambers that are left (and people dying, but that is outside the frame conditions of the experiment).

 

This is where your misunderstanding lies. There is a 50% chance that the referee has put a bullet in this gun. Not in this chamber. You don't know which gun you have. You might have the empty gun.

 

Think of it like this: You have a total of 12 available barrels. 1 barrel has the bullet. 

Initial chance: 1/12

second chance 1/11

third chance 1/10

4th chance 1/9

5th chance 1/8

6th chance: 1/7.

 

It doesn't matter what random subset of barrels you take the first 5 samples from. If there wasn't a bullet yet, it has to be in the next 7 barrels.




#5098497 lit sphere shader

Posted by WarAmp on 03 October 2013 - 11:35 AM

You may also try searching the term "MatCap" or "Material Capture" as this is very similar (if not the same) as that. Render your lights and material to a sphere, then use that resulting image as your lighting environment. Essentially you are precomputing light+material interaction for lights fixed to the viewpoint.

 

http://cgcookie.com/unity/2013/02/18/introduction-to-matcaps-in-unity/




#5096519 Self-shadowing terrain idea - asking for feedback

Posted by WarAmp on 24 September 2013 - 06:17 PM

This is called "Horizon Mapping" (http://research.microsoft.com/en-us/um/people/cohen/bs.pdf) iirc.  Your implementation of 2 values per point will only work for 1 axis of light though. Take your image for example, what happens when the sun moves over the sky to the other side and begins to set? The occlusion heights from that direction are different, and now your precomputed 2 values are no longer correct.




#4974880 Rectangle

Posted by WarAmp on 30 August 2012 - 01:00 PM

You will need to give us more than just your drawing code if you want us to help with a collision issue :)

It's likely that you are only testing ballvec.X/Y in your collision routine rather than the whole Rectangle, show us how you are determining the collision and 'bounce' and we can help you further :)


#4971531 What do I do with this?

Posted by WarAmp on 20 August 2012 - 10:41 AM

struct MyVertex
{
float x, y, z;  // Vertex
float nx, ny, nz; // Normal
float u, v;   // Texcoords
float a, r, g, b; // Color
float padding[4];
};


My openGL is a bit rusty, but I believe you want the value passed into the gl*Pointer() functions to actually point to the part of the struct that is relevant.
ie:
glNormalPointer(  GL_FLOAT, sizeof(MyVertex), &(*RenderListIT)->RenderMesh->VertexData.nx  );
glTexCoordPointer( 2, GL_FLOAT, sizeof(MyVertex), &(*RenderListIT)->RenderMesh->VertexData.u  );
glColorPointer(  3, GL_FLOAT, sizeof(MyVertex), &(*RenderListIT)->RenderMesh->VertexData.a  );
//etc....



#4940727 heading to position transform angle in C++

Posted by WarAmp on 16 May 2012 - 12:40 PM

If you are just trying to transform [0, 360] to [180, -180] then just:

newAngle = 180 - angle;

But what would really help us help you is some context. We can sort of see that you are having a problem with OpenAL, but other than just saying 'Not hearable at certain angles' we have no idea what you are doing vs. what the result is you are trying to achieve. Maybe even draw us some pictures to illustrate the problem?

Spend some time explaining the situation and we can spend more time trying to help. The more information you give us, the more we have to work with.


#4932588 Camera position in spotlight cone

Posted by WarAmp on 18 April 2012 - 03:15 PM

By 'radius for cap' I assume you mean the width of the light at the maximum range?
If so, the angle of the cone is simply given by our old nemesis, Trigonometry.

Tan(angle) = Opposite / Adjacent. In our case, that translates to Tan(angle) = CapRadius/Range

So to get our cosAngle, we do
float angle = atan(Spotlight.CapRadius / Spotlight.Range);
Spotlight.cosAngle = cos(angle);

I recommend just calculating that value once for each spotlight and storing it.


#4932555 Camera position in spotlight cone

Posted by WarAmp on 18 April 2012 - 02:09 PM

First, compute the distance from the camera to the spotlight. If this distance is greater than the range of the spotlight, then you are not in the cone.

Second, take that Vector that you used for the distance, and dot it with the facing vector of the spotlight. If that value is LESS than the cosine of the angle of the cone, you are OUTSIDE the cone. Else you are in.

bool IsCameraInSpotlightCone
{
	 Vector toCamera = Camera.Position - Spotlight.Position;
	 float dist = toCamera.Length();
	 if (dist > Spotlight.Range)
	 {
		  return false;
	 }
	 toCamera /= dist; 	
	 float cosAngle = dot(toCamera, Spotlight.Direction);
	 if (cosAngle < Spotlight.cosAngle)
	 {
		  return false;
	 }
	 return true;
}



#4865279 Atmospheric Scattering - Out-scattering integral solution?

Posted by WarAmp on 23 September 2011 - 02:09 PM

I'm not sure if this should be here or in the Math & Physics forum, if the mods want to move it, I won't complain. :)

I think I may have solved the Out-scattering integral as given in the GPU-Gems 2 article on atmospheric scattering.

I've written a solution and explanation on my crappy blog.

I would love it if some of you fine folks could go over my solution for me and let me know if I'm right, and perhaps even figure out how to apply it to solving the full In-scattering integral as well.

Thanks!


PARTNERS