- Home /
Set image or texture on only particular part of a sphere
Hello Everybody,
I am creating application similar to google earth.
Initially I have set one image on sphere.
I have written C#-script for Rotating sphere using Mouse and Zooming sphere using Mouse double click and Mouse Scroll Wheel like google earth.
Now when I will zoom sphere at that time I want to render image on perticular part (Clicked Part) of sphere only.
Can anybody suggest me what to do for that ?
If anybody can provide me any sample piece of code then it will be better.
Thanks in advance.
Answer by Mojtaba · Jul 25, 2011 at 10:17 AM
You can change the texture of sphere material to a larger texture.
renderer.material.mainTexture = _largerTexture;
You just need to check the position of mouse click on sphere using raycast and load related larger texture.
Thank you AliAzin for the feedback,
I can load larger texture of World $$anonymous$$ap up to some Zoom Level, But when Zoom Level is very high at that time the size of Whole World $$anonymous$$ap will be very large, at that time it is not feasible to render whole image on to sphere.
So that I want to render Part of World $$anonymous$$ap image on to Specific Portion of the Sphere so that no need to render whole image.
Is there any way to do this thing ?
Thanks.
Answer by Alec-Slayden · Jul 25, 2011 at 05:34 PM
That's an interesting problem. There are means of fiddling with UVs that I'm not really sure of, but if I were to tackle the problem without that knowledge, here's what I would try (although you will lose some color detail without tweaking).
I would have my globe sphere, but then I'd also have 2 copies of the globe, which I cut into hemispheres, roughly N/S/E/W. When a target is selected for a zoom, one of these hemispheres will be in full view at a certain magnitude. To help this along, I'd fiddle with their rotation so that there is no spot that is too close to a crease on ALL hemispheres.
These hemispheres would be given a properly aligned texture of higher resolution, and since the surface area is half the size of the sphere, there won't be a larger file size. These are initially inactive, and very slightly smaller in scale than the globe (so they're beneath the surface).
For the first order of magnitude or two, the globe is probably fine. Once it's been determined what hemisphere we're looking at (perhaps through clever collider use earlier), that hemisphere becomes active, and the alpha of the globe fades, and now we have a high res hemisphere for another order of magnitude or two.
We can't keep chopping up the globe to smaller bits, of course, so what I would do next is gather up and organize all my smaller scale maps, and use a light projector (in a static position) pointed at the sphere's surface from a perpendicular axis. From here, any zoom you want to do is trading between 2 projectors: the initial one, and one that is closer to the surface. The first one fades out as the closer one fades in (presumeably once it is filling the view). Since you can't Really keep walking the projectors closer forever, Once you're that close it might be easier to choreograph movement of the projectors or their parameters rather than moving the camera much, since you'll likely be approaching the clip plane. This can give the illusion of further magnitude.
Obviously this requires a lot of choreography in animating the alpha of the globe, the material of the hemisphere, and the intensity of the projectors, and thats if you don't try going further than the second projector in magnitude... But that's probably what I'd try.
EDIT: there's always going to be an intersecting crease with the hemispheres, so... it would have to be 3 copies, so 2 extra hemispheres will make up for that spot (on the bright side there wouldn't have to be any rotational fiddling)
Thank you Alec Slayden,
I am rotating and zoo$$anonymous$$g sphere throught C# scripting.
When user $$anonymous$$ouser Over or Double Click on the Sphere I am getting logitude and latitude of the sphere.
I am getting image from Bing $$anonymous$$ap using this Logitude and Latitude value and want to set in particular part of Sphere only and this will be totaly dynamic through C# script.
I am not aware of 3D concept and not aware of any 3d software and unity. But I am good at program$$anonymous$$g in C# and want to do this thing using C# scripting.
Is there any way to accomplish this thing ?
Thank you.
Perhaps through the use of only projectors as you get closer to the sphere? Though I have had trouble with their color quality myself
Your answer
Follow this Question
Related Questions
Special question about collision thingy 0 Answers
Changing two different objects renderer colour 1 Answer
areas(continents) on my spherical planet 1 Answer
Changing material on prefab 0 Answers
Issue with Mesh Renderer and Skinned Mesh Renderer 0 Answers