• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By isu diss
      How do I fill the gap between sky and terrain? Scaling the terrain or procedural terrain rendering?

    • By lucky6969b
      I've finished a class that can generate textures using the perlin noise function on the fly. The texture may be 2D or 3D. Also, I've seen a guy who can generate vector fields using perlin noise, but the problem is, when you do iterations to the 3D environment, you just have one value to turn, which is a scalar perhaps, and you want to do three things (yaw, pitch and roll), is it possible to generate a 3D vector field using the 3D perlin noise function?
      thanks
      Jack
    • By Jiraya
      For a 2D game, does using a float2 for position increases performance in any way?
      I know that in the end the vertex shader will have to return a float4 anyway, but does using a float2 decreases the amount of data that will have to be sent from the CPU to the GPU?
       
    • By Cahit Karahan

       
      Hi, I'm new in this forum. It is honorable to see such communities exist. I would like to share my new game. I did for android with unity. I know the game is a little awkward , but you have to know that this game is from the time when Unity's name is Unity3D  I have made my first game when I was 12. Now I am 22.  I have taken a lot of experience in this process and I can make better games nowadays. I have published this game nowadays but actually this game is very old but also it is very special for me :))
      I have just wanted to retouch and share this game, because it has a very important place for me.
       
      DESCRIPTION FROM GOOGLE PLAY STORE

      It's a special free 3D horror adventure action game for the halloween. Fun with scary sound effects and musics, 3D realistic graphics, you will feel the horror in the deep of your heart. Use your reflex. Totally free adventure. Totally scary horror game. 

      Tamarra, she is a beast from our world. She needs to consume souls from innocent people to stay alive. Story begins, the old Elaris tribe had lost their everything because of this beast who lived in the well. Araknas was the most powerful warrior of the tribe. One day, Araknas's mother was killed by the servant beasts of Tamarra. That's how Araknas's journey to the well begins. Tamara's well is guarded by horrible beasts. Araknas has to pass all servant beasts until he reaches Tamarra.

      Even death at the end is worth the revenge. 
      Are you brave enough to jump into Tamarra's well?

      Survive from witch attacks, clown attacks and many scary creature.

      - Realistic 3D graphics.
      - Scary sounds.
      - Scary musics.
      - Best experience with headphones.
      - A demon cage where you can imprison all the demons one by one
      - The witches do not like help, but they love blood stone. Witch store where you can develop your abilities and get new abilities.
      - Countless beasts.
      - At the end of the well there is a hidden surprise for you.

      *We do not recommend this game to people with clown phobia, spider phobia, or panic attacks.*

      **!!!**Note : This game is an early-access game, we are upgrading new features every day, new beasts, new improvements, as an example online 1vs1 fall on the list, so stay on connect and follow Halloween : Horror Well on Google Play.**!!!**

  • Advertisement
  • Advertisement

Help with frustum-culling.

Recommended Posts

Hello,

I've been working on some culling-techniques for a project. We've built our own engine so pretty much everything is built from scratch. I've set up a frustum with the following code, assuming that the FOV is 90 degrees.

float angle = CU::ToRadians(45.f);

Plane<float> nearPlane(Vector3<float>(0, 0, aNear), Vector3<float>(0, 0, -1));
Plane<float> farPlane(Vector3<float>(0, 0, aFar), Vector3<float>(0, 0, 1));

Plane<float> right(Vector3<float>(0, 0, 0), Vector3<float>(angle, 0, -angle));
Plane<float> left(Vector3<float>(0, 0, 0), Vector3<float>(-angle, 0, -angle));
Plane<float> up(Vector3<float>(0, 0, 0), Vector3<float>(0, angle, -angle));
Plane<float> down(Vector3<float>(0, 0, 0), Vector3<float>(0, -angle, -angle));

myVolume.AddPlane(nearPlane);
myVolume.AddPlane(farPlane);
myVolume.AddPlane(right);
myVolume.AddPlane(left);
myVolume.AddPlane(up);
myVolume.AddPlane(down);

When checking the intersections I am using a BoundingSphere of my models, which is calculated by taking the average position of all vertices and then choosing the furthest distance to a vertex for radius. The actual intersection test looks like this, where the "myFrustum90" is the actual frustum described above.
The orientationInverse is the viewMatrix in this case.

bool CFrustum::Intersects(const SFrustumCollider& aCollider)
{
		CU::Vector4<float> position = CU::Vector4<float>(aCollider.myCenter.x, aCollider.myCenter.y, aCollider.myCenter.z, 1.f) * myOrientationInverse;
		return myFrustum90.Inside({ position.x, position.y, position.z }, aCollider.myRadius);
}

The Inside() function looks like this.

template <typename T>
bool PlaneVolume<T>::Inside(Vector3<T> aPosition, T aRadius) const
{
	for (unsigned short i = 0; i < myPlaneList.size(); ++i)
	{
		if (myPlaneList.ClassifySpherePlane(aPosition, aRadius) > 0)
		{
			return false;
		}
	}
	return true;
}

And this is the ClassifySpherePlane() function. (The plane is defined as a Vector4 called myABCD, where ABC is the normal)

template <typename T>
inline int Plane<T>::ClassifySpherePlane(Vector3<T> aSpherePosition, float aSphereRadius) const
{
	float distance = (aSpherePosition.Dot(myNormal)) - myABCD.w;
		// completely on the front side
	if (distance >= aSphereRadius)
	{
		return 1;
	}
		// completely on the backside (aka "inside")
	if (distance <= -aSphereRadius)
	{
		return -1;
	}
		//sphere intersects the plane
	return 0;
}

 

Please bare in mind that this code is not optimized nor well-written by any means. I am just looking to get it working.
The result of this culling is that the models seem to be culled a bit "too early", so that the culling is visible and the models pops away.
How do I get the culling to work properly?
I have tried different techniques but haven't gotten any of them to work.
If you need more code or explanations feel free to ask for it.

Thanks.

 

Edited by Baemz
The full post didn't come through at creation. Here comes the rest.

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Advertisement