3D Shpere map

Ok, so im in the process of making a 3D spherical map for my space game. One camera is the players view, the other camera only renders the map and I have it siting in the corner of my players camera. I have a few problems.

First off there should be no skybox texture on the map camera. This has been a bug for so long, I reported it a while ago. This needs to be fixed please. :?

Second part of my problem. I want my sphere map to overlay seamlessly as a part of my HUD. At the moment it does not do this because it is in a overlayed camera and obviously cameras are square. Is there any way to have that camera not render the skybox so that my sphere map lays seamlessly in my HUD. I kinda think of it as using the skybox as a transparentcy layer for that camera. Any idea of how to do some thing like that?

Thanks a bunch, Bill

You need to turn the Clear Flag of your HUD Camera to “Depth only”… If I’m reading what you’re trying to do correctly.

OH SNAP, du… :sweat_smile: thank you. But that still leaves the skybox problem. It doesnt affect me now but it sould be fixed!

Bill

The SkyBox, hmm, I always have to go into the Render Settings and set it up there. If you don’t want one at all then clear the player Camera at solid color? I’m not sure, play around with the Camera settings a bit.

Cameras have a skybox component. This is for setting different skybox’s for cameras in the same scene. But it hasnt worked. It never has. Thats what im talking about.

Well I have had issues setting a skybox on the camera itself too. Like antenna I have to set it from the render settings to be sure.

Setting the camera to clear at a solid color like antenna said should work. I have never done it on purpose, but I was wondering why my skybox wouldn’t show, and it was because of the clear setting. Try it out if you haven’t already. :slight_smile:

-Jeremy

I have been doing that to, but the skybox component for cameras should work.

Well heres a peak at my 3D radar, it needs better graphics but it works!

-Bill

Oh man, that’s a killer HUD map :wink:

Looks really cool, how’s the performance on rendering both scenes?

Im only rendering one scene, but I have divided objects into 2 layers one layer is the map layer the other is the player layer. That shpere is centered always on the players ship. The map camera is very far away to get the entire map.

The large ships/stations will apear like in the example. The small ships will apear as icons. All the small ships will have a billboard attached to each one that only renders only in the map layer.

The performance seems to be fine, barley noticeable difference. Although I havnt tested it with many objects yet.

Bill

No, I meant with the 2 Cameras on one scene equalling 2 scenes, but you have it under control if you’re going to use billboards on the HUD. Very cool, looking forward to a playable example.

I sorta knew you were talking about 2 cameras. I jus thought I sould explain any way. :roll:

Yeah there would be no point in actually rendering small ships, to small to even see.

This is just the start of the map. You will hopfully be able to enlarge the map to full screen and rotate it with the mouse for easy viewing and even have long range sensors from there. We will see how far I go :smile:

Im glad you think it looks cool, it will look better with a full HUD and every thing textured.

-Bill

How might I go about making the sphere so it works some thing like a mask. Only rendering whats inside of it. Is this possible? Any one got an idea? Could this be done with a shader?

I have sat and stared at it for about 20 minutes now thinking how I might do this. :?

Thanks Bill

Distance from center of sphere? Vector3.Distance? Set an invisible target object in the center and use that for distance calculation. If object is within sphere radius, then render it. Is that sort of what you are looking for?

-Jeremy

Well I already thought of that for small ships, they will be using billboard icons in the map.

But for large ships I would like the sphere to actually mask the ship. So lets say a station is half way in range of the sensors, I would like the camera only to only render the part of the station thats in the shpere.

I dont know if this is even possible just throwing it out there.

-Bill

Any idears at all?

Bill

This would be like a real-time boolean intersection function. This is something I want to do too for other reasons, but I don’t think it will be possible… way too computationally expensive.

You could make a circular mask around your HUD that would mask off larger ships entering, but a true spherical mask is real head scratcher.

If I understand you correctly, you have a sphere centered on your ship. If so, could you use triggers, and change an object’s layer when it enters the sphere, then change it when it moves out of the sphere via scripting?

Would it? I was thinking… and in normal rendering if you put a object in another object you cant see it. In my mind it seems like you would flipping the rendering order. If it were a solid sphere (with no transparency) and the camera was inside this shpere, and a object intersected the sphere of course you would only see the part of the object poking in. I would think some kind of shader would be able to only render the mesh that was on the inside. While the camera was on the ouside. Probably very hard and unrealistic (time involved).

I think that what I will do instead of just changing layers is have the object fade it’s alpha after it is outside the shpere, This will be good for the sensor affect because farther away it gets the more hazy it gets. We will see, there are few ways of making it disappear after it leaves the sphere.

-Bill

Half a solution would be to reverse the normals of your HUD sphere and turn it opaque… then you’re looking at the inside of the sphere (the back half) from the outside, and at least big ships coming toward you would slowly enter into the sphere.

But this takes away your nice semi-transparent HUD and only works for ships in front of you coming into view.

I was actually talking to neil earlyer today and we came up with a few solutions. First and most importantly, he asked his friend if there was some way to do what I wanted in a shader. Turnes out you can, and it’s relativly simple.

He gave me this code as a exmaple, it’s not in shader lab but it’s some where to start.

// vertex shader
uniform mat4 modelMatrix;
 
varying vec3 worldSpacePosition;
 
void main()
{
    gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
    gl_FrontColor = gl_Color;
    gl_Position = ftransform();
    worldSpacePosition = (modelMatrix * gl_Vertex).xyz;
}
 
// fragment shader
uniform sampler2D texture;
 
uniform vec3 sphereCenter;
uniform float sphereRadius;
 
varying vec3 worldSpacePosition;
 
void main()
{
    float squareRadius = sphereRadius * sphereRadius;
    vec3 displacement = sphereCenter - worldSpacePosition;
    float squareDistance = dot(displacement, displacement);
 
    if (squareDistance > squareRadius)
    {
        discard;
    }
 
    gl_FragColor = gl_Color * texture2D(texture, gl_TexCoord[0].st);
}

It’s really cool, I didnt even know you could do stuff like that with a shader. It seems to easy :expressionless:

The only problem with doing this method is it leaves a hole in the object. So I came up with the idea of maybe making the inside of the object a solid color and neil pointed out that there is a GL feature that allows different lighting on the front and back of a face.

Any ways what this all comes down to is that while the shader tuts are ok, where is the best place to go to learn a little more about Cg? The shader lab tuts are good for the basics but I need more. Where do I go for more Cg documentation?

Bill