- Home /
color of texture skybox
I'm working with google cardboard. In my main scene I have a skybox with an image as texture. How can I get the color of the pixel I'm looking? The skybox is an element of mainCamera, that is child of "Head". I put also GvrReticle as child of head; is it useful for my purpose? Thanks
The probably easy way (thought of that while writing the now second suggestion): Render the camera into a render texture and also raycast forward. If everything in the scene has a collider or trigger and you don't hire anything, the center pixel you rendered is the skybox pixel.
second approach: if the skybox is a box I would assume that every corner and edge lies at a 45 degree view angle depending on the world axis. using transform.forward of your camera should give you the direction your looking into by their x,y and z value in world space. two Dot products with both the perpendiculars should give you the sin value for the x and y coordinate needed on the skybox texture you'd have to map onto a 0 to 1 scale (cosin? donno). this mapped onto the rectangle of the part of the skybox texture should give you the pixel you want. Prove me wrong but since you can't raycast the sky I don't know of an easier way.