Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Jonesy19 · Nov 29, 2017 at 05:12 PM · shadereditorbuildrenderingimport

Shader isn't displaying properly in editor view, but when built it displays properly.

Hey everyone, I have an issue where my shader is showing up as white in the editor and the game view. When I build it, it plays and renders properly. Originally, when I imported the shader, it displayed properly in the editor view, but once I restarted Unity, it then showed up as white in the editor. I tried reimporting it, yet that did not work. Any ideas? Also, the shader is below.

Thanks!

Here is the shader:

 /*
     Created by chenjd
     http://www.cnblogs.com/murongxiaopifu/
 */
 Shader "chenjd/ForceField"
 {
 Properties
 {
     _Color("Color", Color) = (0,0,0,0)
     _NoiseTex("NoiseTexture", 2D) = "white" {}
     _DistortStrength("DistortStrength", Range(0,1)) = 0.2
     _DistortTimeFactor("DistortTimeFactor", Range(0,1)) = 0.2
     _RimStrength("RimStrength",Range(0, 10)) = 2
     _IntersectPower("IntersectPower", Range(0, 3)) = 2
 }
 
 SubShader
 {
     ZWrite Off
     Cull Off
     Blend SrcAlpha OneMinusSrcAlpha
 
     Tags
     {
         "RenderType" = "Transparent"
         "Queue" = "Transparent"
     }
 
     GrabPass
     {
         "_GrabTempTex"
     }
 
 Pass
 {
     CGPROGRAM
 #pragma target 3.0
 #pragma vertex vert
 #pragma fragment frag
 
 #include "UnityCG.cginc"
 
     struct appdata
 {
     float4 vertex : POSITION;
     float2 uv : TEXCOORD0;
     float3 normal : NORMAL;
 };
 
 struct v2f
 {
     float4 vertex : SV_POSITION;
     float2 uv : TEXCOORD0;
     float4 screenPos : TEXCOORD1;
     float4 grabPos : TEXCOORD2;
     float3 normal : NORMAL;
     float3 viewDir : TEXCOORD3;
 };
 
 sampler2D _GrabTempTex;
 float4 _GrabTempTex_ST;
 sampler2D _NoiseTex;
 float4 _NoiseTex_ST;
 float _DistortStrength;
 float _DistortTimeFactor;
 float _RimStrength;
 float _IntersectPower;
 
 sampler2D _CameraDepthTexture;
 
 v2f vert(appdata v)
 {
     v2f o;
     o.vertex = UnityObjectToClipPos(v.vertex);
 
     o.grabPos = ComputeGrabScreenPos(o.vertex);
 
     o.uv = TRANSFORM_TEX(v.uv, _NoiseTex);
 
     o.screenPos = ComputeScreenPos(o.vertex);
 
     COMPUTE_EYEDEPTH(o.screenPos.z);
 
     o.normal = UnityObjectToWorldNormal(v.normal);
 
     o.viewDir = normalize(UnityWorldSpaceViewDir(mul(unity_ObjectToWorld, v.vertex)));
 
     return o;
 }
 
 fixed4 _Color;
 
 
 fixed4 frag(v2f i) : SV_Target
 {
     float sceneZ = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.screenPos)));
     float partZ = i.screenPos.z;
 
     float diff = sceneZ - partZ;
     float intersect = (1 - diff) * _IntersectPower;
 
     float3 viewDir = normalize(UnityWorldSpaceViewDir(mul(unity_ObjectToWorld, i.vertex)));
     float rim = 1 - abs(dot(i.normal, normalize(i.viewDir))) * _RimStrength;
     float glow = max(intersect, rim);
 
     float4 offset = tex2D(_NoiseTex, i.uv - _Time.xy * _DistortTimeFactor);
     i.grabPos.xy -= offset.xy * _DistortStrength;
     fixed4 color = tex2Dproj(_GrabTempTex, i.grabPos);
 
     fixed4 col = _Color * glow + color;
     return col;
 
 }
 
 ENDCG
 }
 }
 }
Comment
Add comment · Show 2
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 Jonesy19 · Dec 04, 2017 at 01:52 AM 0
Share

Has anyone seen this before?

avatar image Jonesy19 · Dec 09, 2017 at 11:31 PM 0
Share

Does anyone have any ideas? Places I can look? What would cause a shader to be completely white? I will accept ideas at this point.

Thanks!

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

144 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

Related Questions

Distribute terrain in zones 3 Answers

What causes this build log message: "Shader import version has changed; will reimport all shaders..." 2 Answers

Different result in built game and play mode. 2 Answers

Serious Rendering Issue - editor vs build 3 Answers

Why does the app run fluent in the editor but lags when it's built? 2 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