Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Aubrey-Falconer · Feb 13, 2018 at 08:15 AM · renderingrendertexturescripting-underthehood

How to read cubemap from realtime reflection probe

  • I'm using an ocean rendering system which accepts an input cubemap for reflections. My scenes are generated dynamically. I have a reflection probe in my scene which is set to "Realtime > Via Scripting > Individual Faces".

  • Even after calling _probe.RenderProbe(), both _probe.bakedTexture and _probe.customBakedTexture are null and the static ReflectionProbe.defaultTexture variable returns a "UnityBlackCube" Cubemap. How do I access the internal cubemap texture generated by this render probe?

  • Relevant docs: https://docs.unity3d.com/ScriptReference/ReflectionProbe.html

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Remy_Unity · Feb 13, 2018 at 09:13 AM

And what about _probe.texture ?

https://docs.unity3d.com/ScriptReference/ReflectionProbe-texture.html

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Aubrey-Falconer · Feb 13, 2018 at 06:41 PM 0
Share

Hey thanks! Looks like _probe.texture should indeed contain the dynamically rendered cubemap texture, but this still isn't working for me. Attempting to assign _probe.texture to a UnityEngine.Cubemap variable results in a "cannot convert source type" error, while attempting to cast the .texture to (Cubemap) results in a similar failure. I have successfully used statically baked EXR cubemaps generated by reflection probes for cubemap reflections, but can't find the way to accomplish this at runtime. Should I give up and use Camera.RenderToCubemap, or is there a way to use the texture generated by the probe I am already maintaining in my scene?

avatar image Remy_Unity Aubrey-Falconer · Feb 14, 2018 at 08:33 AM 0
Share

Ok, I tried replicating what you are doing by rendering a probe via script, with individual faces, and set back this probe texture to an other one.

Take a look at this doc page : https://docs.unity3d.com/ScriptReference/Rendering.ReflectionProbeTimeSlicing$$anonymous$$ode.IndividualFaces.html

It mentions that updating the cubemap will take 14 frames. What you need to do in your case is to call _probe.RenderProbe() 14 times before trying to get _probe.texture. This will allow all faces of the probe + mips to get correctly rendered and available in _probe.texture.

Best thing to do is to use the render ID returned by _probe.RenderProbe() to check if it is finished rendering with _probe.IsRinishedRendering(int renderID), or set your probe to render in one frame.

Here's a the script I made for example:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.Rendering;
 
 [RequireComponent(typeof(ReflectionProbe))]
 public class ReflectionCopy : $$anonymous$$onoBehaviour
 {
     ReflectionProbe reflectionProbe;
     [SerializeField] ReflectionProbe target;
 
     int renderID;
 
     // Use this for initialization
     void Start ()
     {
         if (target == null)
         {
             enabled = false;
             return;
         }
 
         reflectionProbe = GetComponent<ReflectionProbe>();
         reflectionProbe.refresh$$anonymous$$ode = ReflectionProbeRefresh$$anonymous$$ode.ViaScripting;
         reflectionProbe.timeSlicing$$anonymous$$ode = ReflectionProbeTimeSlicing$$anonymous$$ode.IndividualFaces;
         Destroy( reflectionProbe.texture );
 
         target.mode = ReflectionProbe$$anonymous$$ode.Custom;
 
         renderID = reflectionProbe.RenderProbe();
     }
     
     // Update is called once per frame
     void Update ()
     {
         if (reflectionProbe.IsFinishedRendering(renderID))
         {
             target.customBakedTexture = reflectionProbe.texture;
             // Render Again
             renderID = reflectionProbe.RenderProbe();
         }
     }
 }
avatar image Aubrey-Falconer Remy_Unity · Feb 14, 2018 at 08:59 PM 0
Share

Thanks Remy! I appreciate you testing this. The real challenge is in assigning the final probe texture to a cubemap. I was chatting with a few other devs yesterday, and our consensus was that the only apparent way to accomplish this would be manually, via a series of SetPixels calls. If this is indeed the case, I am probably better off using a Camera.RenderToCubemap approach even given the double performance hit and apparent decrease in quality: https://forum.unity.com/threads/quality-of-mipmaps-by-rendertocubemap-are-not-consistent-with-that-of-default-reflection-probe.436271/

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

82 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Writing to RWTexture3D using a pixel shader without using Graphics.Blit 0 Answers

Irregular shape window to a different background world? 0 Answers

Render object ID to texture 2 Answers

Low resolution RenderTexture is jitter 0 Answers

RenderTexture captured from camera with post effects only shows the emission pass. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges