private TextureBillboardNode(ITextureSource textureSource, int width, int height, IBufferSource model, RenderUnitBuilder builder) : base(model, builder) { this.TextureSource = textureSource; this.Width = width; this.Height = height; }
public void SetData(ITextureSource src) { GPUStateMachine.BindTexture(0, src.GetTextureTarget(), id); switch (src.GetDimensions()) { case 1: GL.TexImage1D(src.GetTextureTarget(), src.GetLevels(), src.GetInternalFormat(), src.GetWidth(), 0, src.GetFormat(), src.GetType(), src.GetPixelData()); break; case 2: GL.TexImage2D(src.GetTextureTarget(), src.GetLevels(), src.GetInternalFormat(), src.GetWidth(), src.GetHeight(), 0, src.GetFormat(), src.GetType(), src.GetPixelData()); break; case 3: GL.TexImage3D(src.GetTextureTarget(), src.GetLevels(), src.GetInternalFormat(), src.GetWidth(), src.GetHeight(), src.GetDepth(), 0, src.GetFormat(), src.GetType(), src.GetPixelData()); break; } GL.GenerateMipmap((GenerateMipmapTarget)src.GetTextureTarget()); GPUStateMachine.UnbindTexture(0, src.GetTextureTarget()); this.Width = src.GetWidth(); this.Height = src.GetHeight(); this.Depth = src.GetDepth(); this.LevelCount = src.GetLevels(); this.format = src.GetFormat(); this.internalformat = src.GetInternalFormat(); this.texTarget = src.GetTextureTarget(); }
private TextureBillboardRenderer(ITextureSource textureSource, int width, int height, IBufferable model, IShaderProgramProvider shaderProgramProvider, AttributeMap attributeMap, params GLState[] switches) : base(model, shaderProgramProvider, attributeMap, switches) { this.TextureSource = textureSource; this.Width = width; this.Height = height; }
private void InitLoadingScreen() { /* final */ ITextureSource loadingScreenTextureSource = this.mEngineOptions.GetLoadingScreenTextureSource(); /* final */ Texture loadingScreenTexture = TextureFactory.CreateForTextureSourceSize(loadingScreenTextureSource); /* final */ TextureRegion loadingScreenTextureRegion = TextureRegionFactory.CreateFromSource(loadingScreenTexture, loadingScreenTextureSource, 0, 0); this.SetScene(new SplashScene(this.GetCamera(), loadingScreenTextureRegion)); }
/// <summary> /// Prepares all colliders. Deletes previous BoxColliders2D and adds new by using Quadtree. Also fits them correctly with texture. /// /// <para>Thanks for /u/idbrii for pointing out overkill in deletion/addition of BoxColliders2D.</para> /// </summary> /// <param name="pixelData">List of columns (chunk data) to find potential colliding pixels</param> public void UpdateColliders(List <Column> pixelData, ITextureSource textureSource) { PPU = textureSource.PPU; Vector2Int textureSize = new Vector2Int(textureSource.Texture.width, textureSource.Texture.height); if (rects != null) { rects.Clear(); } List <BoxCollider2D> colls = new List <BoxCollider2D>(gameObject.GetComponents <BoxCollider2D>()); rects = new List <Rect>(); QuadTreeToRect(pixelData, 0, 0, textureSize.x, textureSize.y); //Assume all colliders would be deleted. We use enabled for that. foreach (BoxCollider2D b in colls) { b.enabled = false; } //For each Rect found from Columns (Quadtree in QuadTreeToRect)... foreach (Rect r in rects) { //Newly created collider will have an offset equeal to that. Vector2 rColliderOffset = new Vector2(r.x + r.size.x / 2, r.y + r.size.y / 2f); //Find already existing BoxCollider2D that would fit newly created BoxCollider2D. BoxCollider2D boxC = colls.Find(coll => coll.offset == rColliderOffset && coll.size == r.size); if (!boxC) { //Not found? Create new one. BoxCollider2D b = gameObject.AddComponent <BoxCollider2D>(); b.offset = rColliderOffset; b.size = r.size; } else { //Found. It won't be deleted! boxC.enabled = true; } } //All BoxColliders2D that were modified and haven't been found are deleted. foreach (BoxCollider2D b in colls) { if (b.enabled == false) { Destroy(b); } } }
/// <summary> /// Creates a billboard in 3D world. Its size is described by Width\Height(in pixels). /// </summary> /// <param name="textureSource"></param> /// <param name="width"></param> /// <param name="height"></param> /// <returns></returns> public static TextureBillboardRenderer Create(ITextureSource textureSource, int width, int height) { var vertexShader = new VertexShader(vertexCode);// this vertex shader has no vertex attributes. var fragmentShader = new FragmentShader(fragmentCode); var provider = new ShaderArray(vertexShader, fragmentShader); var map = new AttributeMap(); var renderer = new TextureBillboardRenderer(textureSource, width, height, new Billboard(), provider, map); renderer.Initialize(); return(renderer); }
/// <summary> /// Creates a billboard in 3D world. Its size is described by Width\Height(in pixels). /// </summary> /// <param name="textureSource"></param> /// <param name="width"></param> /// <param name="height"></param> /// <returns></returns> public static TextureBillboardNode Create(ITextureSource textureSource, int width, int height) { var vs = new VertexShader(vertexCode);// this vertex shader has no vertex attributes. var fs = new FragmentShader(fragmentCode); var provider = new ShaderArray(vs, fs); var map = new AttributeMap(); var builder = new RenderUnitBuilder(provider, map); var node = new TextureBillboardNode(textureSource, width, height, new Billboard(), builder); node.Initialize(); return(node); }
IEnumerator getTextImage(string url, string text) { WWWForm form = new WWWForm(); form.AddField("text", text); WWW request = new WWW(url, form); while (!request.isDone) { yield return(null); } defaultTexture = request.texture; textureSource = new ImageSource(defaultTexture); }
public CubeMap(ITextureSource left, ITextureSource front, ITextureSource right, ITextureSource back, ITextureSource top, ITextureSource bottom) { Left = left; Front = front; Right = right; Back = back; Top = top; Bottom = bottom; }
public static FullScreenNode Create(ITextureSource textureSource) { var model = new FullScreenModel(); var map = new AttributeMap(); var vs = new VertexShader(secondPassVert); var fs = new FragmentShader(secondPassFrag); var array = new ShaderArray(vs, fs); var secondPassBuilder = new RenderMethodBuilder(array, map); var node = new FullScreenNode(model, secondPassBuilder); node.textureSource = textureSource; node.Initialize(); return(node); }
void Start() { if (defaultTexture != null) { textureSource = new ImageSource(defaultTexture); textureMat = textureSource.mat; } else if (!String.IsNullOrEmpty(text)) { string url = "https://3l8h6kvhvg.execute-api.ap-northeast-1.amazonaws.com/dev/text"; StartCoroutine(getTextImage(url, text)); } else { textureSource = new VideoSource(); } }
/// <summary> /// /// </summary> /// <param name="textureSource">source of texture.</param> public CtrlTexture(ITextureSource textureSource) : base(GUIAnchorStyles.Left | GUIAnchorStyles.Top) { var model = new CtrlTextureModel(); var vs = new VertexShader(vert); var fs = new FragmentShader(frag); var codes = new ShaderArray(vs, fs); var map = new AttributeMap(); map.Add(inPosition, CtrlTextureModel.position); map.Add(inUV, CtrlTextureModel.uv); var methodBuilder = new RenderMethodBuilder(codes, map, new BlendFuncSwitch(BlendSrcFactor.SrcAlpha, BlendDestFactor.OneMinusSrcAlpha)); this.RenderUnit = new ModernRenderUnit(model, methodBuilder); this.textureSource = textureSource; this.Initialize(); }
/// Initialization when the scene is started. This sets up the source of dynamic texture generation for the display. /// Based on the current choice of DisplayModes, the DisplayTexturePipelineFactory will provide the appropriate /// ITextureSource. void Start() { OnionLogger.globalLog.PushInfoLayer("Initializing Display"); texture = new Texture2D(textureWidth, textureHeight, TextureFormat.RGB24, false); this.renderer.material.mainTexture = texture; switch (displayMode) { case (DisplayModes.HORAY): textureSource = DisplayTexturePipelineFactory.BuildStandardHORAYConfig(); break; case (DisplayModes.InvHORAY): textureSource = DisplayTexturePipelineFactory.BuildBlackOnWhiteHORAYConfig(); break; case (DisplayModes.FakeTexture): textureSource = DisplayTexturePipelineFactory.BuildFakeTextureSource(); break; case (DisplayModes.FakeImage): textureSource = DisplayTexturePipelineFactory.BuildWithFakeImageSource(); break; case (DisplayModes.FakeProbeOutput): textureSource = DisplayTexturePipelineFactory.BuildWithFakeBModeProbeOutput(); break; case (DisplayModes.GaussianBlurTest): textureSource = DisplayTexturePipelineFactory.BuildWithGaussianBlurImageSource(); break; default: UltrasoundDebug.Assert(false, "Unknown display mode!", this); break; } OnionLogger.globalLog.PopInfoLayer(); }
public CubeMapTextureSource(CubeMapFace face, ITextureSource tex) { curFace = face; texSrc = tex; }
public SkyBoxMap(ITextureSource skyBoxImage) { SkyBoxImage = skyBoxImage; }
public TextureMap(ITextureSource texture, PointToUV map) { Texture = texture; Map = map; }
public void UpdateColliders(List <Column> pixelData, ITextureSource textureSource) { //Doesnt do anything. }