GL NEAREST和GL LINEAR的選擇

2021-07-27 08:57:54 字數 1201 閱讀 6157

gl_nearest和gl_linear

前者表示「使用紋理中座標最接近的乙個畫素的顏色作為需要繪製的畫素顏色」,

後者表示「使用紋理中座標最接近的若干個顏色,通過加權平均演算法得到需要繪製的畫素顏色」。

前者只經過簡單比較,需要運算較少,可能速度較快,

後者需要經過加權平均計算,其中涉及除法運算,可能速度較慢(但如果有專門的處理硬體,也可能兩者速度相同)。

從視覺效果上看,前者效果較差,在一些情況下鋸齒現象明顯,後者效果會較好(但如果紋理圖象本身比較大,則兩者在視覺效果上就會比較接近)。

gl.teximage2d(gl.texture_2d, 0, gl.rgba, gl.rgba, gl.unsigned_byte, textures[0].image);

gl.texparameteri(gl.texture_2d, gl.texture_mag_filter, gl.nearest);

gl.texparameteri(gl.texture_2d, gl.texture_min_filter, gl.nearest);

gl.bindtexture(gl.texture_2d, textures[1]);

gl.teximage2d(gl.texture_2d, 0, gl.rgba, gl.rgba, gl.unsigned_byte, textures[1].image);

gl.texparameteri(gl.texture_2d, gl.texture_mag_filter, gl.linear);

gl.texparameteri(gl.texture_2d, gl.texture_min_filter, gl.linear);

gl.bindtexture(gl.texture_2d, textures[2]);

gl.teximage2d(gl.texture_2d, 0, gl.rgba, gl.rgba, gl.unsigned_byte, textures[2].image);

gl.texparameteri(gl.texture_2d, gl.texture_mag_filter, gl.linear);

gl.texparameteri(gl.texture_2d, gl.texture_min_filter, gl.linear_mipmap_nearest);

gl.generatemipmap(gl.texture_2d);

和 區別和聯絡, 和 區別和聯絡

和 區別和聯絡,和 區別和聯絡,實際專案中,什麼情況用哪種?首先,和 的聯絡 共同點 和 都可以用作 邏輯與 運算子,都是雙目運算子。具體要看使用時的具體條件來決定。無論使用哪種運算子,對最終的運算結果都沒有影響。情況1 當上述的運算元是boolean型別變數時,和 都可以用作邏輯與運算子。情況2 ...

rpx和樣式和class和flex

5 style 靜態的樣式統一寫到 class 中。style 接收動態的樣式,在執行時會進行解析,請盡量避免將靜態的樣式寫進 style 中,以免影響渲染速度。例 6 class 用於指定樣式規則,其屬性值是樣式規則中類選擇器名 樣式類名 的集合,樣式類名不需要帶上.樣式類名之間用空格分隔。關於f...

if和switch和for語句

if和switch很像。具體什麼場景下,應用那個語句呢?如果判斷的具體數值不多,而是符合byte,short,int,char,字串。這五種型別。雖然兩個語句都可以使用,建議使用switch語句,因為效率稍高。其他情況,對區間判斷,對結果為boolean型別判斷,使用if,if的使用範圍更廣。whi...