void InitFramebuffers() { screen_w = Screen.width; screen_h = Screen.height; Vector2 simv = GetResolution(sim_resolution); Vector2 dyev = GetResolution(dye_resolution); simWidth = (int)simv.x; simHeight = (int)simv.y; dyeWidth = (int)dyev.x; dyeHeight = (int)dyev.y; FilterMode filtering = supportLinearFiltering?FilterMode.Bilinear:FilterMode.Point; if (density_dfbo == null) { density_dfbo = CreateDoubleFBO(dyeWidth, dyeHeight, 0, format_rgba, filtering); } else { density_dfbo = ResizeDoubleFBO(density_dfbo, dyeWidth, 0, dyeHeight, format_rgba, filtering); } if (velocity_dfbo == null) { velocity_dfbo = CreateDoubleFBO(simWidth, simHeight, 0, format_rg, filtering); } else { velocity_dfbo = ResizeDoubleFBO(velocity_dfbo, simWidth, 0, simHeight, format_rg, filtering); } divergence_fbo = CreateFBO(simWidth, simHeight, 0, format_r, filtering); curl_fbo = CreateFBO(simWidth, simHeight, 0, format_r, filtering); pressure_dfbo = CreateDoubleFBO(simWidth, simHeight, 0, format_r, filtering); InitBloomFramebuffers(dyeWidth, dyeHeight, 0, format_rgba, filtering); }
DoubleFBO ResizeDoubleFBO(DoubleFBO target, int w, int h, int d, RenderTextureFormat format, FilterMode filterMode) { target.SetReadFBO(ResizeFBO(target.GetReadFBO(), w, h, 0, format, filterMode)); target.SetWriteFBO(CreateFBO(w, h, 0, format, filterMode)); return(target); }