国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Three.js 材質(zhì)的 blending

這篇具有很好參考價值的文章主要介紹了Three.js 材質(zhì)的 blending。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

Three.js 材質(zhì)的 blending

// blending modes
export type Blending =
    | typeof NoBlending
    | typeof NormalBlending
    | typeof AdditiveBlending
    | typeof SubtractiveBlending
    | typeof MultiplyBlending
    | typeof CustomBlending;

// custom blending destination factors
export type BlendingDstFactor =
    | typeof ZeroFactor
    | typeof OneFactor
    | typeof SrcColorFactor
    | typeof OneMinusSrcColorFactor
    | typeof SrcAlphaFactor
    | typeof OneMinusSrcAlphaFactor
    | typeof DstAlphaFactor
    | typeof OneMinusDstAlphaFactor
    | typeof DstColorFactor
    | typeof OneMinusDstColorFactor;

// custom blending equations
export type BlendingEquation =
    | typeof AddEquation
    | typeof SubtractEquation
    | typeof ReverseSubtractEquation
    | typeof MinEquation
    | typeof MaxEquation;

// custom blending src factors
export const SrcAlphaSaturateFactor: 210;
export type BlendingSrcFactor = typeof SrcAlphaSaturateFactor;

// custom blending destination factors
export type BlendingDstFactor =
    | typeof ZeroFactor
    | typeof OneFactor
    | typeof SrcColorFactor
    | typeof OneMinusSrcColorFactor
    | typeof SrcAlphaFactor
    | typeof OneMinusSrcAlphaFactor
    | typeof DstAlphaFactor
    | typeof OneMinusDstAlphaFactor
    | typeof DstColorFactor
    | typeof OneMinusDstColorFactor;

class Material {
  blending: Blending;

  blendEquation: BlendingEquation;
  blendEquationAlpha: BlendingEquation;

  blendDst: BlendingDstFactor;
  blendDstAlpha: BlendingDstFactor;

  blendSrc: BlendingSrcFactor | BlendingDstFactor;
  blendSrcAlpha: BlendingSrcFactor | BlendingDstFactor;
}
1、blending

材質(zhì)的混合模式。

id = gl.BLEND

// NoBlending
gl.disable( id );

// NormalBlending
// AdditiveBlending
// SubtractiveBlending
// MultiplyBlending
// CustomBlending
gl.enable( id );
2、blendEquation

混合公式確定如何將新像素與 中 WebGLFramebuffer 已有的像素組合。

混合方程的API:
gl.blendEquationSeparate: 用于分別設(shè)置 RGB 混合方程和 alpha 混合方程
gl.blendEquation: RGB 混合方程和 alpha 混合方程設(shè)置為單個方程。

// blending:
//      NormalBlending
//      AdditiveBlending
//      SubtractiveBlending
//      MultiplyBlending
gl.blendEquation( gl.FUNC_ADD );

// blending:
//      CustomBlending
gl.blendEquationSeparate(
    equationToGL[ blendEquation ],
    equationToGL[ blendEquationAlpha ]
);

混合方程的值:

const equationToGL = {
    [ AddEquation ]: gl.FUNC_ADD,
    [ SubtractEquation ]: gl.FUNC_SUBTRACT,
    [ ReverseSubtractEquation ]: gl.FUNC_REVERSE_SUBTRACT
    [ MinEquation ]: gl.MIN
    [ MaxEquation ]: gl.MAX
};

source: 接下來要畫的顏色
destination: 已經(jīng)畫在了幀緩沖區(qū)中的顏色

AddEquation: source + destination
SubtractEquation: source - destination
ReverseSubtractEquation: destination - source
MinEquation: Math.min(source, destination)
MaxEquation: Math.max(source, destination)
3、blendFunc

用于混合像素算法的函數(shù)。

混合函數(shù)API:
gl.blendFunc: RGB 和 alpha 設(shè)置為單個混合函數(shù)。
gl.blendFuncSepar: 分別混合 RGB 和 alpha 分量的混合函數(shù)。

// 混合像素算法的函數(shù)
// sfactor: source 混合因子
// dfactor: destination 混合因子
gl.blendFunc(sfactor, dfactor)

// sourceColor: vec4;
// color(RGBA) = (sourceColor * sfactor) + (destinationColor * dfactor)
// srcRGB: source RGB 混合因子
// dstRGB: destination RGB 混合因子
// dstRGB: source A 混合因子
// dstRGB: dstAlpha RGB 混合因子
blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha)

// sourceColor: vec3;
// sourceAlpha: float;
// color(RGB) = (sourceColor * srcRGB) + (destinationColor * dstRGB)
// color(A) = (sourceAlpha * srcAlpha) + (destinationAlpha * dstAlpha)
// blending = NormalBlending
gl.blendFuncSeparate(
    gl.SRC_ALPHA,
    gl.ONE_MINUS_SRC_ALPHA,
    gl.ONE,
    gl.ONE_MINUS_SRC_ALPHA
);

// blending = AdditiveBlending
gl.blendFunc( gl.SRC_ALPHA, gl.ONE );

// blending = SubtractiveBlending
gl.blendFuncSeparate(
    gl.ZERO,
    gl.ONE_MINUS_SRC_COLOR,
    gl.ZERO,
    gl.ONE
);

// blending = MultiplyBlending
gl.blendFunc( gl.ZERO, gl.SRC_COLOR );

// blending = CustomBlending
gl.blendFuncSeparate(
    factorToGL[ blendSrc ],
    factorToGL[ blendDst ],
    factorToGL[ blendSrcAlpha ],
    factorToGL[ blendDstAlpha ]
);

混合因子的值:

const factorToGL = {
    [ ZeroFactor ]: gl.ZERO,
    [ OneFactor ]: gl.ONE,

    [ SrcColorFactor ]: gl.SRC_COLOR,
    [ SrcAlphaFactor ]: gl.SRC_ALPHA,
    [ SrcAlphaSaturateFactor ]: gl.SRC_ALPHA_SATURATE,

    [ DstColorFactor ]: gl.DST_COLOR,
    [ DstAlphaFactor ]: gl.DST_ALPHA,

    [ OneMinusSrcColorFactor ]: gl.ONE_MINUS_SRC_COLOR,
    [ OneMinusSrcAlphaFactor ]: gl.ONE_MINUS_SRC_ALPHA,
    [ OneMinusDstColorFactor ]: gl.ONE_MINUS_DST_COLOR,
    [ OneMinusDstAlphaFactor ]: gl.ONE_MINUS_DST_ALPHA
};

R S , G S , B S , A S R_S, G_S, B_S, A_S RS?,GS?,BS?,AS?, source 的 RGBA.
R D , G D , B D , A D R_D, G_D, B_D, A_D RD?,GD?,BD?,AD?, destination 的 RGBA.

Factor RGB A
Zero ( 0 , 0 , 0 ) (0,0,0) (0,0,0) 0
One ( 1 , 1 , 1 ) (1,1,1) (1,1,1) 1
SrcColor ( R S , G S , B S ) (R_S, G_S, B_S) (RS?,GS?,BS?) A S A_S AS?
SrcAlpha ( A S , A S , A S ) (A_S, A_S, A_S) (AS?,AS?,AS?) A S A_S AS?
SrcAlphaSaturate ( f , f , f ) ; f = m i n ( A S , 1 ? A D ) (f,f,f);f=min(A_S, 1 - A_D) (f,f,f);f=min(AS?,1?AD?) 1 1 1
DstColor ( R D , G D , B D ) (R_D, G_D, B_D) (RD?,GD?,BD?) A D {A_D} AD?
DstAlpha ( A D , A D , A D ) (A_D, A_D, A_D) (AD?,AD?,AD?) A D {A_D} AD?
OneMinusSrcColor $(1,1,1) - (R_S, G_S, B_S) $ A S A_S AS?
OneMinusSrcAlpha ( 1 , 1 , 1 ) ? ( A S , A S , A S ) (1,1,1) - (A_S, A_S, A_S) (1,1,1)?(AS?,AS?,AS?) 1 ? A S 1-A_S 1?AS?
OneMinusDstColor ( 1 , 1 , 1 ) ? ( R D , G D , B D ) (1,1,1) - (R_D, G_D, B_D) (1,1,1)?(RD?,GD?,BD?) 1 ? A D 1-A_D 1?AD?
OneMinusDstAlpha ( 1 , 1 , 1 ) ? ( A D , A D , A D ) (1,1,1) - (A_D, A_D, A_D) (1,1,1)?(AD?,AD?,AD?) 1 ? A D 1-A_D 1?AD?
4、live examples

WebGL “port” of this.

gl.blendFunc()
gl.blendFuncSeparate()文章來源地址http://www.zghlxwxcb.cn/news/detail-732384.html

到了這里,關(guān)于Three.js 材質(zhì)的 blending的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔相關(guān)法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • Three.js 實現(xiàn)模型材質(zhì)分解,拆分,拆解效果

    Three.js 實現(xiàn)模型材質(zhì)分解,拆分,拆解效果

    原理:通過修改模型材質(zhì)的 x,y,z 軸坐標 positon.set( x,y,z) 來實現(xiàn)拆解,分解的效果。 注意:支持模型材質(zhì)position 修改的材質(zhì)類型為 type=“Mesh” ,其他類型的材質(zhì)修改了 position 可能沒有實際效果 在上一篇 Three.js加載外部glb,fbx,gltf,obj 模型文件 的文章基礎(chǔ)上新增一個 setModelMeshD

    2024年02月11日
    瀏覽(42)
  • Three.js——基礎(chǔ)材質(zhì)、深度材質(zhì)、法向材質(zhì)、面材質(zhì)、朗伯材質(zhì)、Phong材質(zhì)、著色器材質(zhì)、直線和虛線、聯(lián)合材質(zhì)

    Three.js——基礎(chǔ)材質(zhì)、深度材質(zhì)、法向材質(zhì)、面材質(zhì)、朗伯材質(zhì)、Phong材質(zhì)、著色器材質(zhì)、直線和虛線、聯(lián)合材質(zhì)

    個人簡介 ?? 個人主頁: 前端雜貨鋪 ???♂? 學習方向: 主攻前端方向,正逐漸往全干發(fā)展 ?? 個人狀態(tài): 研發(fā)工程師,現(xiàn)效力于中國工業(yè)軟件事業(yè) ?? 人生格言: 積跬步至千里,積小流成江海 ?? 推薦學習:??前端面試寶典 ??Vue2 ??Vue3 ??Vue2/3項目實戰(zhàn) ??Node.js??

    2024年04月27日
    瀏覽(21)
  • threejs點擊獲取三維坐標(Three.js獲取鼠標點擊的三維坐標)

    綁定點擊事件,通過 THREE.Raycaster 光線投射,用于確定鼠標點擊位置上有哪些物體, raycaster.intersectObjects(scene.children) 返回點擊位置上所有的物體的數(shù)組;我們用 var selected = intersects[0] 取第一個,也就是最前面的那個物體;在通過 selected.point 取點坐標

    2024年02月11日
    瀏覽(91)
  • 【js&threeJS】入門three,并實現(xiàn)3D汽車展示廳,附帶全碼

    【js&threeJS】入門three,并實現(xiàn)3D汽車展示廳,附帶全碼

    首先放個最終效果圖: ? 三維(3D)概念: 三維(3D)是一個描述物體在三個空間坐標軸上的位置和形態(tài)的概念。相比于二維(2D)只有長度和寬度的平面,三維增加了高度或深度這一維度 在三維空間中,我們使用三個獨立的坐標軸來描述物體的位置。通常使用笛卡爾坐標系

    2024年02月11日
    瀏覽(703)
  • Three.js--》前端開發(fā)者掌握3d技術(shù)不再是夢,初識threejs

    Three.js--》前端開發(fā)者掌握3d技術(shù)不再是夢,初識threejs

    ????????這十年來 web 得到了快速的發(fā)展,隨著 webgl 的普及,網(wǎng)頁的表現(xiàn)能力越來越強大,網(wǎng)頁上已經(jīng)開始可以做出很多復(fù)雜的動畫和精美的效果,還可以通過 webgl 在網(wǎng)頁中繪制高性能的3d圖形,別的不說,凡是入門程序員都離不開github這個網(wǎng)站,細心的人都會發(fā)現(xiàn),gi

    2024年02月01日
    瀏覽(98)
  • Three.js之幾何體、高光材質(zhì)、渲染器設(shè)置、gui

    陣列立方體和相機適配體驗 Threejs常見幾何體簡介 … gui.js庫(可視化改變?nèi)S場景) 注:基于Three.js v0.155.0 長方體:BoxGeometry 球體:SphereGeometry 圓柱:CylinderGeometry 矩形平面:PlaneGeometry 圓形平面:CircleGeometry 高光網(wǎng)格材質(zhì):MeshPhongMaterial(shininess、specular) WebGL渲染器設(shè)置:

    2024年02月11日
    瀏覽(28)
  • Three.js實現(xiàn)模型,模型材質(zhì)可拖拽效果 DragControls

    Three.js實現(xiàn)模型,模型材質(zhì)可拖拽效果 DragControls

    DragControls:是一個用于在Three.js中實現(xiàn)拖拽控制的輔助類。它簡化了在Three.js中實現(xiàn)拖拽物體的過程。 DragControls的構(gòu)造函數(shù)接受三個參數(shù): objects:一個包含需要進行拖拽的物體的數(shù)組。 camera:相機對象,用于將屏幕坐標轉(zhuǎn)換為三維空間坐標。 domElement:渲染器的DOM元素,用于

    2024年02月11日
    瀏覽(19)
  • Three.js Tri-panner (三面貼圖) 材質(zhì) 兩種實現(xiàn)方式

    Three.js Tri-panner (三面貼圖) 材質(zhì) 兩種實現(xiàn)方式

    介紹 Tri-panner 在babylonjs中有支持 但是three.js目前的基礎(chǔ)材質(zhì)并不支持 需要自己定義shader 或者使用目前還沒有什么完善的文檔的 NodeMaterial 下面展示兩種實現(xiàn)方式 自定義shader NodeMaterial 這是threejs新系統(tǒng)充滿未來 目前還沒有一個完善的文檔 并且不太穩(wěn)定 r132的時候支持這個材質(zhì)

    2024年01月18日
    瀏覽(25)
  • VUE使用Three.js實現(xiàn)模型,點擊交互,相機旋轉(zhuǎn)視角跟隨移動(Threejs中使用Tweenjs,含demo源碼)

    VUE使用Three.js實現(xiàn)模型,點擊交互,相機旋轉(zhuǎn)視角跟隨移動(Threejs中使用Tweenjs,含demo源碼)

    目錄 一、Three.js是什么? 二、VUE簡單使用Three.js步驟 1.npm安裝 2.template模板 3.引入庫 4.定義全局變量 5.初始化場景 6.初始化相機 7.初始化燈光 8.初始化渲染器 9.創(chuàng)建模型(這里我搭建的模型是一個簡單雙面貨架模型) 10.根據(jù)瀏覽器窗口自適應(yīng) 11.初始化函數(shù),頁面加載完成時調(diào)用

    2024年02月03日
    瀏覽(104)
  • Unity中Shader的混合模式Blend

    Unity中Shader的混合模式Blend

    Unity中Shader的混合模式Blend 這里用PS里的混合作為例子 沒選擇混合效果前,顯示的效果是這樣 選擇了混合效果后,顯示的效果就是這樣 之前代碼中寫的 Blend one one 第一個 one 代表源顏色 第二個 one 代表目標顏色 BlendOP默認是 + (Add) 混合因子 One:源或目標的完整值 Zero:0 S

    2024年04月15日
    瀏覽(17)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包