Announcement

Collapse
No announcement yet.

cubeRenderTarget to 2D texture?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    cubeRenderTarget to 2D texture?

    I can't seem to figure out how to pipe a captureCube's render target into a normal 2D texture... It only seems to work with something like a WS reflection vector. I just want to use the resulting latLong map it creates as a texture on another surface. Is this possible?

    #2
    Nothing?

    Comment


      #3
      I bump this post because i'm looking for this solution too
      You mean that you want the realtime sphere texture ?

      Comment


        #4
        I'm pretty sure it is just a standard Render Texture and therefore usable as like a normal texture, do you have a screenshot of what you have tried?

        Comment


          #5
          I already post it, but the answer didn't works

          https://forums.unrealengine.com/show...ight=spherical

          Thx

          Comment


            #6
            Erodann, Sorry I completely misunderstood your question in the other thread. I thought by "not reflection" you meant you didn't want it flipped

            This is happening since the engine automatically remaps UV coordates for cube sources such as HDR textures or cube targets to use the spherical format. You can counteract it using math or you can bring in your texture as a non-HDR format to sample it regularly.

            To do this, Martin Mittring sent me the formula the engine uses to convert under the hood which is this:

            float2((1 + atan2(NormalizedDirection.x, - NormalizedDirection.y) / 3.14159265) / 2, acos(NormalizedDirection.z) / 3.14159265)

            Reversing those operations gives this math:

            float2 regUV = (UV.x-1)*3.14159265*2;
            regUV = float2(-sin(regUV.x),cos(regUV.y));
            return float3(regUV.x, regUV.y, cos(UV.y*3.14159265));

            that goes into a custom node with one input called "UV" Then you plug in texture coordinate and it returns a square texture value. Enjoy!
            Last edited by RyanB; 05-18-2015, 12:11 PM.
            Ryan Brucks
            Principal Technical Artist, Epic Games

            Comment


              #7
              also as i said in the other post thank you so much for the answer but there are a probleme :S



              Thank you by advance
              Attached Files

              Comment


                #8
                weird, the Y coordinate needs to be multiplied by 2 still. use this instead:

                float2 regUV = (UV.x-1)*3.14159265*2;
                regUV = float2(-sin(regUV.x),cos(regUV.y));
                return float3(regUV.x, regUV.y, cos(UV.y*3.14159265)*2);

                This doesn't make sense to me though since in the original code it never had that factor of 2 there.. hmmm will need to figure out why
                Ryan Brucks
                Principal Technical Artist, Epic Games

                Comment


                  #9
                  actually this is still not quite right. hold on, dont worry will figure it out in a minute its very close.

                  backwards math is sometimes tricky since the order of operations is all reversed.
                  Ryan Brucks
                  Principal Technical Artist, Epic Games

                  Comment


                    #10
                    haha indeed, i have a little probleme with the top and the bottom

                    i'll wait for you

                    Comment


                      #11
                      3rd times a charm fwiw I am making this a material function using regular nodes (not custom node) that will be available in a future ue4 version:


                      float2 Angles = float2(2 * PI * (UV.x + 0.5f), PI * UV.y);

                      float s = sin(Angles.y);
                      float3 Direction = float3(s * sin(Angles.x), cos(Angles.y), -s * cos(Angles.x));

                      return Direction.xzy;
                      Ryan Brucks
                      Principal Technical Artist, Epic Games

                      Comment


                        #12
                        haha thank you so much RyanB D
                        It's working ! You rock !!

                        Comment


                          #13
                          Thank you for posting this!!! I'll try this tonight!

                          Comment


                            #14
                            Can you do a paste of the blueprint code? Me and C are not friends
                            Last edited by 3dlight; 05-28-2015, 03:54 PM.

                            Comment


                              #15
                              Originally posted by 3dlight View Post
                              Can you do a paste of the blueprint code? Me and C are not friends
                              That's HLSL code, you can create a 'Custom' node in the Material Editor, and copy & paste that in there. That's all you gotta do!

                              You need to give it a UV Input (Vector 2) though.

                              Comment

                              Working...
                              X