we had something similar. works in unity, not in a build. but if I created 2 of them… one was blank and one worked.
in the end never quite exactly figured it out… but after removing glow/blur component from the render camera, it worked !
I doubt that your issue is the same, but you never know.
Thanks Jonny, but I dont think its the same issue. The render textures are not attached to a camera. I use Graphics Blit to write into the textures.
Ok, kinda got it to work. I have a function that initializes some stuff ( InitMaps() ). This is called from the Start function and when the user presses the space bar to reset the simulation. When the space bar is hit in the web player the simulation resets and you can then see everything like normal. But the simluation should start straight away. This is not happening in the web player for some reason.
This is the script. This works fine in Unity just not in the web player.
#pragma strict
var heightMaps : RenderTexture[];
var fluxMaps : RenderTexture[];
var guiTex : RenderTexture;
var fluxMat : Material;
var velocityMat : Material;
var guiMat : Material;
var initMat : Material;
private var idx : int = 0;
private var noiseTex : Texture2D;
function Start()
{
if(SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBFloat))
{
heightMaps[0].format = RenderTextureFormat.ARGBFloat;
heightMaps[1].format = RenderTextureFormat.ARGBFloat;
fluxMaps[0].format = RenderTextureFormat.ARGB32;
fluxMaps[1].format = RenderTextureFormat.ARGB32;
}
else if(SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBHalf))
{
print("Looks like your graphics card does not support 32 bit floating point textures. Simulation my contain artfacts.");
heightMaps[0].format = RenderTextureFormat.ARGBHalf;
heightMaps[1].format = RenderTextureFormat.ARGBHalf;
fluxMaps[0].format = RenderTextureFormat.ARGBHalf;
fluxMaps[1].format = RenderTextureFormat.ARGBHalf;;
}
else
{
print("Looks like your graphics card does not support floating point textures. Simulation will contain artfacts.");
}
fluxMat.SetFloat("_TexSize", fluxMaps[0].width);
velocityMat.SetFloat("_TexSize", fluxMaps[0].width);
noiseTex = new Texture2D(heightMaps[0].width, heightMaps[0].height);
InitMaps();
}
function Update()
{
//If space bar hit reset the simulation
if(Input.GetKeyDown(KeyCode.Space)) InitMaps();
var idx0 : int = idx % 2;
var idx1 : int = (idx+1) % 2;
fluxMat.SetTexture("_HtTex", heightMaps[idx0]);
Graphics.Blit(fluxMaps[idx0], fluxMaps[idx1], fluxMat);
velocityMat.SetTexture("_FluxTex", fluxMaps[idx1]);
Graphics.Blit(heightMaps[idx0], heightMaps[idx1], velocityMat);
guiMat.SetTexture("_MainTex", heightMaps[idx1]);
idx++;
}
function InitMaps()
{
//Resets simulation to starting conditions
idx = 0;
fluxMaps[0].DiscardContents();
fluxMaps[1].DiscardContents();
heightMaps[0].DiscardContents();
heightMaps[1].DiscardContents();
FillTextureWithNoise(noiseTex);
//heightMaps[0] must be initilized with a height map source, in this case noiseTex
Graphics.Blit(noiseTex, heightMaps[0], initMat);
}
function FillTextureWithNoise(tex : Texture2D)
{
var perlin : PerlinNoise = new PerlinNoise(Time.realtimeSinceStartup);
for(var x : int = 0; x < tex.width; x++)
{
for(var y : int = 0; y < tex.height; y++)
{
var n : float = perlin.FractalNoise2D(x, y, 8, 400.0, 1.0);
n = (n+1.0)*0.5;
tex.SetPixel(x,y, Color(n,n,n,n));
}
}
tex.Apply();
}
sounds like something isnt initialized… or zeroed out.
possibly in unity, unity clears all vars for you, maybe in web player that might not be the case, and hitting space might reset everything.
Maybe call reset the first time in ?
I just had this problem. For me I resolved it by setting the renderer for the object to to have a material color of white. It seems like the web player over clears some values that should have more practical defaults. Guessing it only happens with programatic creation since I suspect the editor actually sets the defaults rather than falling back on them so they’re actually recorded. Hope this helps someone at some point.