• 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
1
Question by gap · Jun 06, 2012 at 07:45 AM · shader

Crash due to themal effect shader

Hi,

I have problem with the Thermal shader which I applied on the augmented reality camera, I m using qualcomm for the augmented reality,

It is crashing due to some some problem can any one have an Idea where i m wrong in the following code because, as i attach the shader run time.

I ll use following code for the thermal effect.

public var JellyVisionShader : Shader; public var ThermalVisionOnOffFlag : boolean ; //var Manager : mapmanager; var ButtonEnabled : boolean ; var sw1p : float ;
var sh1p : float; public var GuiTexture : GUITexture ; public var GuiText : GUIText ; private var m_CompositeMaterial : Material;

private function GetCompositeMaterial() : Material { if(ThermalVisionOnOffFlag) { if (m_CompositeMaterial == null) { m_CompositeMaterial = new Material(JellyVisionShader); m_CompositeMaterial.hideFlags = HideFlags.HideAndDontSave; } }
return m_CompositeMaterial;

}

private var renderTexture : RenderTexture; private var shaderCamera : GameObject; function Start() { Debug.Log(" Start");

JellyVisionShader = Resources.Load("Shaders/JEllyVisionShader", typeof(Shader)) as Shader; ThermalVisionOnOffFlag = true;

ButtonEnabled = true; sw1p = (Screen.width/100.0f); sh1p = (Screen.height/100.0f);

}

public function GetshaderOn( onoffflag : boolean) { ThermalVisionOnOffFlag = onoffflag;
}

function OnGUI() {

}

function OnPreRender() { if(ThermalVisionOnOffFlag) {

     if (!enabled || !gameObject.active)
         return;
         
     if (renderTexture != null) {
         RenderTexture.ReleaseTemporary (renderTexture);
         renderTexture = null;
     }
     renderTexture = RenderTexture.GetTemporary (camera.pixelWidth, camera.pixelHeight, 16);
     if (!shaderCamera) {
         shaderCamera = new GameObject("ShaderCamera", Camera);
         shaderCamera.camera.enabled = false;
         shaderCamera.hideFlags = HideFlags.HideAndDontSave;
     }
     
     var cam = shaderCamera.camera;
     cam.CopyFrom (camera);
     cam.backgroundColor = Color(0,0,0,0);
     cam.clearFlags = CameraClearFlags.SolidColor;
     cam.targetTexture = renderTexture;
     cam.RenderWithShader (JellyVisionShader, "RenderType");
 }    

}

function OnRenderImage (source : RenderTexture, destination : RenderTexture) : void { if(ThermalVisionOnOffFlag) { var buffer = RenderTexture.GetTemporary(source.width/4, source.height/4, 0);

     var compositeMat = GetCompositeMaterial();
 
     compositeMat.SetTexture ("_MainTex",  buffer);
         
     //ImageEffects.BlitWithMaterial(compositeMat, source, destination);
     Graphics.Blit(source, destination ,compositeMat);
     RenderTexture.ReleaseTemporary(buffer);
     
     
     if (renderTexture != null) {
         RenderTexture.ReleaseTemporary (renderTexture);
         renderTexture = null;
  }
 }

}

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to force the compilation of a shader in Unity? 5 Answers

What are normals? 1 Answer

How to create light like in minecraft? 1 Answer

How to move vertices up/down randomly in shader. 1 Answer

cast shadow - export lightmap from 3ds max to unity 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