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 TigrisGames · Oct 20, 2020 at 06:34 PM · shaderrendering

Screen freezes after running the game [ Shaders problem ]

i'm using the shader below, whene i run the game. it renders one frame and then stops rendering and updating screen, the other scripts are working fine without any problem.

 Shader "The Developer/SS All-in-One Outline"
 {
     Properties
     {
         _OutlineColor("Outline Color", Color) = (1,1,1,1)
         _OutlineThreshold("Outline Threshold", Float) = 3
         _OutlineWidth("Outline Width", Float) = 2
         _DepthMultiplier("Depth Multiplier", Float) = 2
         _EdgeStrengthen ("Edge Strengthen", Float) = 2
         _MainTex ("Texture", 2D) = "white" {}
     }
     SubShader
     {
         // No culling or depth
         // Cull Off ZWrite Off ZTest Always
 
         Pass
         {
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
             #include "UnityCG.cginc"
 
             struct appdata
             {
                 float4 vertex : POSITION;
                 float3 normal : NORMAL;
             };    
 
             struct v2f
             {
                 float4 position : POSITION;
                 float4 screenPos : TEXCOORD0;
             };
 
             fixed4 _OutlineColor;
             half _OutlineThreshold;
             half _OutlineWidth;
             half _DepthMultiplier;
             half _EdgeStrengthen;
             sampler2D _CameraDepthTexture;
             sampler2D _MainTex;
 
             v2f vert(appdata input)
             {
                 v2f output;
 
                 output.position = UnityObjectToClipPos(input.vertex);
                 output.screenPos = output.position;
 
                 return output;
             }
 
             #define PSL01UVC(uv1, uv2) \
                         pow((Linear01Depth(tex2D(_CameraDepthTexture, uv1)) - Linear01Depth(tex2D(_CameraDepthTexture, uv2))), 2) + \
                         pow((SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, uv1) - SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, uv2)) * _DepthMultiplier, 2) + \
                         pow((tex2D(_MainTex, uv1) - tex2D(_MainTex, uv2)) * _EdgeStrengthen, 2)
 
             float4 outline;
             half4 pixel;
             half2 uv;
             half onePixelW, onePixelH;
             fixed i;
             void OutlinePixel(){
                 outline = 0;
                 for(i = 1 ; i <= _OutlineWidth ; i++){
                     outline += 
                             PSL01UVC(half2(uv.x - i * onePixelW, uv.y), 
                                      half2(uv.x + i * onePixelW, uv.y)) + 
 
                             PSL01UVC(half2(uv.x, uv.y + i * onePixelH), 
                                      half2(uv.x, uv.y - i * onePixelH)) + 
 
                             PSL01UVC(half2(uv.x - i * onePixelW, uv.y - i * onePixelH), 
                                      half2(uv.x + i * onePixelW, uv.y + i * onePixelH)) + 
 
                             PSL01UVC(half2(uv.x - i * onePixelW, uv.y + i * onePixelH), 
                                      half2(uv.x + i * onePixelW, uv.y - i * onePixelH));
                 }
             }
 
             half4 frag(v2f input) : SV_Target
             {    
                 uv = input.screenPos.xy / input.screenPos.w;
                 uv.x = (uv.x + 1) * .5;
                 uv.y = (uv.y + 1) * .5;
 
                 pixel = tex2D(_MainTex, uv);
 
                 onePixelW = 1.0 / _ScreenParams.x;
                 onePixelH = 1.0 / _ScreenParams.y;
 
                 OutlinePixel();
 
                 return lerp(pixel, _OutlineColor, (outline.r + outline.g + outline.b) >= _OutlineThreshold ? 1 : 0);
             }    
             ENDCG
         }
     }
 }
 
Comment
Add comment · Show 1
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 3kWikiGames · Oct 20, 2020 at 10:49 PM 0
Share

are you getting any errors?

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

224 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

Specular artifacts on iOS using standard PBR shader on Lightweight render pipeline 0 Answers

Hole Shader in URP 1 Answer

COLORMASK & writing to multiple render targets In Deferred doesn't work as expected in DX9 1 Answer

Static batching changes vertex colors? 0 Answers

Image Effect - Screen coordinates 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