Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 MarkD · Oct 06, 2013 at 05:35 PM · errorshaderreflectionrealtime

Reflection shader color issue

Hello, My name is Mark and I have been developing my game for over a year now, everytime I had a problem the internet, forum and answer section helped me alot. But unfortunatly it has come to a point that I have become stuck. Stuck with shader code to be specific.

Note that I am not a 100% pro shader writer, and this shader is my first advanced one.

The problem:

I am writing an advanced glass shader to simulate glass (ofcourse). Everything is working as expected without any problems, expept one thing. The reflection. I am using a stripped down version of the water script to on the side for my realtime reflection in the shader, I have checked it from top to bottom and there is no error from there. After some digging I found that my problem was inside my shader. In the first pass.

What's happening is that in editor mode with lights off it will reflect everything, but as soon as I put the lights on, it will only reflect the first object to come across.

This is very weird and I am blaffed by the reason for behavior like this.

I have made a stripped down version of my shader isolating the problem and made several screenshots for examples.

I am not asking for you to write to code for me, some insight into the problem would help alot and explaining what I did wrong would be great.

Thanks ahead.

alt text

Stripped down version of the shader, to isolate the problem.

Shader "Glass/Advanced Glass" { Properties { _TexColor ("Detail (RGB)Trans (A)", 2D) = "black" { } _ReflectionTex ("ReflectionTex", 2D) = "black" { TexGen ObjectLinear } }

     SubShader {
         Tags {
              "Queue"="Transparent"
              "IgnoreProjector"="True"
             "RenderType"="Opaque"
                      
         }
         LOD 300
          ZWrite Off
          ColorMask RGBA
         //Lights currently off, when On nothing gets reflected?
          Lighting Off
                // Set reflection to texture
              Pass{
              
                Blend One One 
             //  Blend SrcColor one
         SetTexture[_TexColor] { combine Texture} 
          SetTexture[_ReflectionTex] { Matrix [_ProjMatrix] combine Texture + Primary   }
 
         } 
 
 
 
 
 
         
         //Glass properties 
             CGPROGRAM
        // Upgrade NOTE: exclude shader from OpenGL ES 2.0 it does not contain a surface program or vertex and fragment programs.
             #pragma exclude_renderers gles
             #pragma surface surf BlinnPhong decal:add nolightmap
 //Glass////////////////////////////////////////////////////////////////////////////////////////////////
             sampler2D _TexColor;
             
                  struct Input {
                 float2 uv_TexColor;
                             
                 };
             
             void surf (Input IN, inout SurfaceOutput o) { 
             //draw texture and reflection options 
                 half4  reflcol = tex2D (_TexColor, IN.uv_TexColor);  
                     
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
 
     
             }
         ENDCG  



Edit:

I found some more information about my problem, it seems that this only occurs with the unity buildin shaders, as I use my own shaders the realtime lightmaps are rendered. I am gonna dig trough the unity shaders and if needed rewrite them for my own purpose.

Edit: found the cause!! It seems that the problem is that my render texture's camera does not support pixel lights, It only seems to be rendering the standard ambient light. I used a stripped down version of the reflection script as mentioned before, found on the unity wiki: http://wiki.unity3d.com/index.php/MirrorReflection2

I have digged trough the sripts to enable diferred lighting but it seems that it will only render forward, with a few pixel lights.

Do you guy's have any idea how to enable it?

example.jpg (177.7 kB)
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

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

15 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

Related Questions

transparent + reflection shader (river water problems) 2 Answers

Realtime reflection 1 Answer

Please help me resolve these errors related to shaders. 0 Answers

Surface Reflection Shader with Shadows 0 Answers

Shader Replacement Error 0 Answers


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