- Home /
Black and white effect on mobile?
Hi.
I attached the GrayscaleEffect.cs image effect to my camera and it works perfectly in the Editor.
However, when I builded to my devices the framerate went down to less than 5 FPS when I activated the Grayscale Effect.
How can I create a black and white effect on mobile devices running with a decent framerate?
Best regards, Andreas
what are u doing exactly in your script? If u want to change to something like this you could just change the materials of each object, and it would work ;)
This is the script:
using UnityEngine;
[ExecuteInEdit$$anonymous$$ode]
[AddComponent$$anonymous$$enu("Image Effects/Color Adjustments/Grayscale")]
public class GrayscaleEffect : ImageEffectBase {
public Texture textureRamp;
public float rampOffset;
// Called by camera to apply image effect
void OnRenderImage (RenderTexture source, RenderTexture destination) {
material.SetTexture("_RampTex", textureRamp);
material.SetFloat("_RampOffset", rampOffset);
Graphics.Blit (source, destination, material);
}
}
You are right that it would work by changing each material, but I have a lot of them, so it wouldn't be the best method, unless it's the only one working method for mobile devices of course.
Here I'm back. Ahm. What you simply clould do is something like this. ( sorry, I don't know the exact references for the materials but I try to give you my logic. )
So. This is what I think of. You are making one script. For example. $$anonymous$$aterialchanger.cs
Then u assign the other script that contains the variable that is being activating that grayscale effect. And then you can make a refference to it. The looking script uses update because we want to look each frame. Example script:
using UnityEngine
public class $$anonymous$$aterialchanger : $$anonymous$$onoBehaviour {
public Texture gray; public Texture white;
TheChangingScript TCS;
//catch the activating script void Start() { TCS = FindObjectOfType(TheChangingScript) }
//update each frame and look if TheChangingScripts bool is changing void Update() { //just execute that if it is my networkview if(Networkview.is$$anonymous$$ine == true && TCS.bool == true)
{ material.SetTexture(gray); } else { material.SetTexture(white); } }
}
attach something like that on each object where you would like to change the texture. Good luck!
Your answer
Follow this Question
Related Questions
Image Effects on MovieTexture 0 Answers
Can Paritcle Effects Cause Lag? 1 Answer
Unity3.4 Mobile Terrain Lag 1 Answer
shown like 16bit color image 1 Answer