public static void Texture(RenderTexture rendertexture, Mesh mesh, int submesh, Texture texture, P3dCoord coord) { if (cachedTextureSet == false) { cachedTexture = P3dShader.BuildMaterial("Hidden/Paint in 3D/Texture"); cachedTextureSet = true; } P3dHelper.BeginActive(rendertexture); cachedTexture.SetTexture(P3dShader._Buffer, texture); cachedTexture.SetVector(P3dShader._BufferSize, new Vector2(texture.width, texture.height)); P3dHelper.Draw(cachedTexture, mesh, Matrix4x4.identity, submesh, coord); P3dHelper.EndActive(); }
public static void White(RenderTexture rendertexture, Mesh mesh, int submesh, P3dCoord coord) { P3dHelper.BeginActive(rendertexture); if (mesh != null) { if (cachedWhiteSet == false) { cachedWhite = P3dShader.BuildMaterial("Hidden/Paint in 3D/White"); cachedWhiteSet = true; } GL.Clear(true, true, Color.black); P3dHelper.Draw(cachedWhite, mesh, Matrix4x4.identity, submesh, coord); } else { GL.Clear(true, true, Color.white); } P3dHelper.EndActive(); }
private void CompleteDirectly() { if (tempTexture != null && (tempTexture.width != buffer.width || tempTexture.height != buffer.height)) { tempTexture = P3dHelper.Destroy(tempTexture); } if (tempTexture == null) { tempTexture = new Texture2D(buffer.width, buffer.height, TextureFormat.RGBA32, false); } P3dHelper.BeginActive(buffer); tempTexture.ReadPixels(new Rect(0, 0, buffer.width, buffer.height), 0, 0); P3dHelper.EndActive(); buffer = P3dHelper.ReleaseRenderTexture(buffer); tempTexture.Apply(); OnComplete(tempTexture.GetRawTextureData <Color32>()); }