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 Mehrdad995 · Mar 30, 2020 at 01:37 PM · shadershadersshader programminggraph

Override the reflection probe's texture in shader graph

Hi,
I've implemented a 2 faced (top, bottom) reflection which I stretch by a matrix and use it as my realtime reflection,
I want to access the reflection probe input inside the shader graph's PBR Master node and override the reflection map it has with my custom reflection map,
I know that I can disable reflection probe detection in mesh renderer and just use my reflection map, but
I want to take advantage of the builtin PBR calculations for the reflections (metallic, smoothness, ...).
so, is there any way to override the reflection prob's map in my shader and pass my custom texture as the reflection?

Comment
Add comment · Show 4
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 Namey5 · Mar 31, 2020 at 09:22 AM 1
Share

Aside from reflection strength, those parameters wouldn't do much to a regular cubemap. Unity pre-processes their reflection probes outside of the material to get glossy reflections, if that is what you are after. To replace reflection probes in a shader, you would need to either override the HLSL include files in the SRP package (which would apply to every material), or hand write a shader that uses the Lit shader as reference. In theory, you could just manually override the reflection probe property through script, i.e.

 material.SetTexture ("unity_SpecCube0", customReflection);
 material.SetVector ("unity_SpecCube0_HDR", Vector4.zero);

But even then, I'm not sure it would take precedence over the internal renderer.

avatar image Mehrdad995 Namey5 · Mar 31, 2020 at 05:20 PM 0
Share

hey buddy, thanks a lot
tried what you said but it spams me with this warning:
Trying to set builtin parameter "unity_SpecCube0_HDR". Will be ignored.
and this didn't work.
I can't even use GetTexture on the material, it gives the following error:
$$anonymous$$aterial doesn't have a texture property 'unity_SpecCube0'
Even, if everything was ok, I still had to inject the reflection texture as a cube map.
is there any way to inject it through the shader itself? so I can process my reflections with the matrix beforehand.
I have no problem trying to handwrite the shader if the shader graph doesn't support such functionality.
This is the code I used : using System.Collections; using System.Collections.Generic; using UnityEngine;

 public class ReflProbeReplacer : $$anonymous$$onoBehaviour
 {
     public $$anonymous$$aterial material;
     public Texture customReflection;
     public Vector4 vector4;
     public bool useDefault;
     private Texture defaultReflection;
     private Vector4 defaultVector;
 
     private void Awake()
     {
         defaultReflection = material.GetTexture("unity_SpecCube0");
         defaultVector = material.GetVector("unity_SpecCube0_HDR");
     }
 
     private void LateUpdate()
     {
         if(useDefault)
         {
             material.SetTexture("unity_SpecCube0", defaultReflection);
             material.SetVector("unity_SpecCube0_HDR", defaultVector);
         }
         else
         {
             material.SetTexture("unity_SpecCube0", customReflection);
             material.SetVector("unity_SpecCube0_HDR", vector4);
         }
     }
 }

once again, thanks for caring

avatar image Pangamini · Mar 31, 2020 at 11:31 PM 0
Share

I don't understand, why can't you just override the reflection probe in the mesh renderer? how does that not use the builtin pbr calculations? Also keep in $$anonymous$$d that in deferred renderer, reflection probes are rendered separately, not in the surface shader.

avatar image Mehrdad995 Pangamini · Apr 02, 2020 at 11:53 AM 0
Share

sorry I can't understand what you mean by "overriding the reflection probe in the mesh".
I'm trying to override it in the shader itself because my reflection is a pair of plain texture2Ds rather than a cubemap and I need to stretch and wrap them around the object correctly only by matrix multiplication to mimic ordinary reflections.
currently, I can do such a thing and push them to the Emission input but that would act as a separate reflection ins$$anonymous$$d of the main reflection which gets affected by "metallic" and "smoothness" properties.

0 Replies

· Add your reply
  • Sort: 

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

202 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 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 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

EnableKeyword("_EMISSION") not working 2019.3.13f1 0 Answers

Silhouette overlay shader 0 Answers

Object velocity affect vertex position in shader graph?? 0 Answers

Displace and show normals in fragment shader 1 Answer

Custom UI Shader Stencil Problem [willing to pay for fix] 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