mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
parent
e03825bf08
commit
180e456a8e
102
blend.go
102
blend.go
@ -24,20 +24,20 @@ import (
|
||||
//
|
||||
// The default (zero) value is source-over (regular alpha blending).
|
||||
type Blend struct {
|
||||
// BlendFactorSourceColor is a factor for source RGB values.
|
||||
BlendFactorSourceColor BlendFactor
|
||||
// BlendFactorSourceRGB is a factor for source RGB values.
|
||||
BlendFactorSourceRGB BlendFactor
|
||||
|
||||
// BlendFactorSourceAlpha is a factor for source alpha values.
|
||||
BlendFactorSourceAlpha BlendFactor
|
||||
|
||||
// BlendFactorDestinationColor is a factor for destination RGB values.
|
||||
BlendFactorDestinationColor BlendFactor
|
||||
// BlendFactorDestinationRGB is a factor for destination RGB values.
|
||||
BlendFactorDestinationRGB BlendFactor
|
||||
|
||||
// BlendFactorDestinationAlpha is a factor for destination apha values.
|
||||
BlendFactorDestinationAlpha BlendFactor
|
||||
|
||||
// BlendOperationColor is an operation for source and destination RGB values.
|
||||
BlendOperationColor BlendOperation
|
||||
// BlendOperationRGB is an operation for source and destination RGB values.
|
||||
BlendOperationRGB BlendOperation
|
||||
|
||||
// BlendOperationAlpha is an operation for source and destination alpha values.
|
||||
BlendOperationAlpha BlendOperation
|
||||
@ -45,11 +45,11 @@ type Blend struct {
|
||||
|
||||
func (b Blend) internalBlend() graphicsdriver.Blend {
|
||||
return graphicsdriver.Blend{
|
||||
BlendFactorSourceColor: b.BlendFactorSourceColor.internalBlendFactor(true),
|
||||
BlendFactorSourceRGB: b.BlendFactorSourceRGB.internalBlendFactor(true),
|
||||
BlendFactorSourceAlpha: b.BlendFactorSourceAlpha.internalBlendFactor(true),
|
||||
BlendFactorDestinationColor: b.BlendFactorDestinationColor.internalBlendFactor(false),
|
||||
BlendFactorDestinationRGB: b.BlendFactorDestinationRGB.internalBlendFactor(false),
|
||||
BlendFactorDestinationAlpha: b.BlendFactorDestinationAlpha.internalBlendFactor(false),
|
||||
BlendOperationColor: b.BlendOperationColor.internalBlendOperation(),
|
||||
BlendOperationRGB: b.BlendOperationRGB.internalBlendOperation(),
|
||||
BlendOperationAlpha: b.BlendOperationAlpha.internalBlendOperation(),
|
||||
}
|
||||
}
|
||||
@ -67,7 +67,7 @@ const (
|
||||
BlendFactorDestinationAlpha
|
||||
BlendFactorOneMinusSourceAlpha
|
||||
BlendFactorOneMinusDestinationAlpha
|
||||
BlendFactorDestinationColor
|
||||
BlendFactorDestinationRGB
|
||||
)
|
||||
|
||||
func (b BlendFactor) internalBlendFactor(source bool) graphicsdriver.BlendFactor {
|
||||
@ -90,8 +90,8 @@ func (b BlendFactor) internalBlendFactor(source bool) graphicsdriver.BlendFactor
|
||||
return graphicsdriver.BlendFactorOneMinusSourceAlpha
|
||||
case BlendFactorOneMinusDestinationAlpha:
|
||||
return graphicsdriver.BlendFactorOneMinusDestinationAlpha
|
||||
case BlendFactorDestinationColor:
|
||||
return graphicsdriver.BlendFactorDestinationColor
|
||||
case BlendFactorDestinationRGB:
|
||||
return graphicsdriver.BlendFactorDestinationRGB
|
||||
default:
|
||||
panic(fmt.Sprintf("ebiten: invalid blend factor: %d", b))
|
||||
}
|
||||
@ -135,132 +135,132 @@ var (
|
||||
// BlendSourceOver represents the regular alpha blending.
|
||||
// c_out = c_src + c_dst × (1 - α_src)
|
||||
BlendSourceOver = Blend{
|
||||
BlendFactorSourceColor: BlendFactorOne,
|
||||
BlendFactorSourceRGB: BlendFactorOne,
|
||||
BlendFactorSourceAlpha: BlendFactorOne,
|
||||
BlendFactorDestinationColor: BlendFactorOneMinusSourceAlpha,
|
||||
BlendFactorDestinationRGB: BlendFactorOneMinusSourceAlpha,
|
||||
BlendFactorDestinationAlpha: BlendFactorOneMinusSourceAlpha,
|
||||
BlendOperationColor: BlendOperationAdd,
|
||||
BlendOperationRGB: BlendOperationAdd,
|
||||
BlendOperationAlpha: BlendOperationAdd,
|
||||
}
|
||||
|
||||
// c_out = 0
|
||||
BlendClear = Blend{
|
||||
BlendFactorSourceColor: BlendFactorZero,
|
||||
BlendFactorSourceRGB: BlendFactorZero,
|
||||
BlendFactorSourceAlpha: BlendFactorZero,
|
||||
BlendFactorDestinationColor: BlendFactorZero,
|
||||
BlendFactorDestinationRGB: BlendFactorZero,
|
||||
BlendFactorDestinationAlpha: BlendFactorZero,
|
||||
BlendOperationColor: BlendOperationAdd,
|
||||
BlendOperationRGB: BlendOperationAdd,
|
||||
BlendOperationAlpha: BlendOperationAdd,
|
||||
}
|
||||
|
||||
// c_out = c_src
|
||||
BlendCopy = Blend{
|
||||
BlendFactorSourceColor: BlendFactorOne,
|
||||
BlendFactorSourceRGB: BlendFactorOne,
|
||||
BlendFactorSourceAlpha: BlendFactorOne,
|
||||
BlendFactorDestinationColor: BlendFactorZero,
|
||||
BlendFactorDestinationRGB: BlendFactorZero,
|
||||
BlendFactorDestinationAlpha: BlendFactorZero,
|
||||
BlendOperationColor: BlendOperationAdd,
|
||||
BlendOperationRGB: BlendOperationAdd,
|
||||
BlendOperationAlpha: BlendOperationAdd,
|
||||
}
|
||||
|
||||
// c_out = c_dst
|
||||
BlendDestination = Blend{
|
||||
BlendFactorSourceColor: BlendFactorZero,
|
||||
BlendFactorSourceRGB: BlendFactorZero,
|
||||
BlendFactorSourceAlpha: BlendFactorZero,
|
||||
BlendFactorDestinationColor: BlendFactorOne,
|
||||
BlendFactorDestinationRGB: BlendFactorOne,
|
||||
BlendFactorDestinationAlpha: BlendFactorOne,
|
||||
BlendOperationColor: BlendOperationAdd,
|
||||
BlendOperationRGB: BlendOperationAdd,
|
||||
BlendOperationAlpha: BlendOperationAdd,
|
||||
}
|
||||
|
||||
// c_out = c_src × (1 - α_dst) + c_dst
|
||||
BlendDestinationOver = Blend{
|
||||
BlendFactorSourceColor: BlendFactorOneMinusDestinationAlpha,
|
||||
BlendFactorSourceRGB: BlendFactorOneMinusDestinationAlpha,
|
||||
BlendFactorSourceAlpha: BlendFactorOneMinusDestinationAlpha,
|
||||
BlendFactorDestinationColor: BlendFactorOne,
|
||||
BlendFactorDestinationRGB: BlendFactorOne,
|
||||
BlendFactorDestinationAlpha: BlendFactorOne,
|
||||
BlendOperationColor: BlendOperationAdd,
|
||||
BlendOperationRGB: BlendOperationAdd,
|
||||
BlendOperationAlpha: BlendOperationAdd,
|
||||
}
|
||||
|
||||
// c_out = c_src × α_dst
|
||||
BlendSourceIn = Blend{
|
||||
BlendFactorSourceColor: BlendFactorDestinationAlpha,
|
||||
BlendFactorSourceRGB: BlendFactorDestinationAlpha,
|
||||
BlendFactorSourceAlpha: BlendFactorDestinationAlpha,
|
||||
BlendFactorDestinationColor: BlendFactorZero,
|
||||
BlendFactorDestinationRGB: BlendFactorZero,
|
||||
BlendFactorDestinationAlpha: BlendFactorZero,
|
||||
BlendOperationColor: BlendOperationAdd,
|
||||
BlendOperationRGB: BlendOperationAdd,
|
||||
BlendOperationAlpha: BlendOperationAdd,
|
||||
}
|
||||
|
||||
// c_out = c_dst × α_src
|
||||
BlendDestinationIn = Blend{
|
||||
BlendFactorSourceColor: BlendFactorZero,
|
||||
BlendFactorSourceRGB: BlendFactorZero,
|
||||
BlendFactorSourceAlpha: BlendFactorZero,
|
||||
BlendFactorDestinationColor: BlendFactorSourceAlpha,
|
||||
BlendFactorDestinationRGB: BlendFactorSourceAlpha,
|
||||
BlendFactorDestinationAlpha: BlendFactorSourceAlpha,
|
||||
BlendOperationColor: BlendOperationAdd,
|
||||
BlendOperationRGB: BlendOperationAdd,
|
||||
BlendOperationAlpha: BlendOperationAdd,
|
||||
}
|
||||
|
||||
// c_out = c_src × (1 - α_dst)
|
||||
BlendSourceOut = Blend{
|
||||
BlendFactorSourceColor: BlendFactorOneMinusDestinationAlpha,
|
||||
BlendFactorSourceRGB: BlendFactorOneMinusDestinationAlpha,
|
||||
BlendFactorSourceAlpha: BlendFactorOneMinusDestinationAlpha,
|
||||
BlendFactorDestinationColor: BlendFactorZero,
|
||||
BlendFactorDestinationRGB: BlendFactorZero,
|
||||
BlendFactorDestinationAlpha: BlendFactorZero,
|
||||
BlendOperationColor: BlendOperationAdd,
|
||||
BlendOperationRGB: BlendOperationAdd,
|
||||
BlendOperationAlpha: BlendOperationAdd,
|
||||
}
|
||||
|
||||
// c_out = c_dst × (1 - α_src)
|
||||
BlendDestinationOut = Blend{
|
||||
BlendFactorSourceColor: BlendFactorOneMinusDestinationAlpha,
|
||||
BlendFactorSourceRGB: BlendFactorOneMinusDestinationAlpha,
|
||||
BlendFactorSourceAlpha: BlendFactorOneMinusDestinationAlpha,
|
||||
BlendFactorDestinationColor: BlendFactorZero,
|
||||
BlendFactorDestinationRGB: BlendFactorZero,
|
||||
BlendFactorDestinationAlpha: BlendFactorZero,
|
||||
BlendOperationColor: BlendOperationAdd,
|
||||
BlendOperationRGB: BlendOperationAdd,
|
||||
BlendOperationAlpha: BlendOperationAdd,
|
||||
}
|
||||
|
||||
// c_out = c_src × α_dst + c_dst × (1 - α_src)
|
||||
BlendSourceAtop = Blend{
|
||||
BlendFactorSourceColor: BlendFactorDestinationAlpha,
|
||||
BlendFactorSourceRGB: BlendFactorDestinationAlpha,
|
||||
BlendFactorSourceAlpha: BlendFactorDestinationAlpha,
|
||||
BlendFactorDestinationColor: BlendFactorOneMinusSourceAlpha,
|
||||
BlendFactorDestinationRGB: BlendFactorOneMinusSourceAlpha,
|
||||
BlendFactorDestinationAlpha: BlendFactorOneMinusSourceAlpha,
|
||||
BlendOperationColor: BlendOperationAdd,
|
||||
BlendOperationRGB: BlendOperationAdd,
|
||||
BlendOperationAlpha: BlendOperationAdd,
|
||||
}
|
||||
|
||||
// c_out = c_src × (1 - α_dst) + c_dst × α_src
|
||||
BlendDestinationAtop = Blend{
|
||||
BlendFactorSourceColor: BlendFactorOneMinusDestinationAlpha,
|
||||
BlendFactorSourceRGB: BlendFactorOneMinusDestinationAlpha,
|
||||
BlendFactorSourceAlpha: BlendFactorOneMinusDestinationAlpha,
|
||||
BlendFactorDestinationColor: BlendFactorSourceAlpha,
|
||||
BlendFactorDestinationRGB: BlendFactorSourceAlpha,
|
||||
BlendFactorDestinationAlpha: BlendFactorSourceAlpha,
|
||||
BlendOperationColor: BlendOperationAdd,
|
||||
BlendOperationRGB: BlendOperationAdd,
|
||||
BlendOperationAlpha: BlendOperationAdd,
|
||||
}
|
||||
|
||||
// c_out = c_src × (1 - α_dst) + c_dst × (1 - α_src)
|
||||
BlendXor = Blend{
|
||||
BlendFactorSourceColor: BlendFactorOneMinusDestinationAlpha,
|
||||
BlendFactorSourceRGB: BlendFactorOneMinusDestinationAlpha,
|
||||
BlendFactorSourceAlpha: BlendFactorOneMinusDestinationAlpha,
|
||||
BlendFactorDestinationColor: BlendFactorOneMinusSourceAlpha,
|
||||
BlendFactorDestinationRGB: BlendFactorOneMinusSourceAlpha,
|
||||
BlendFactorDestinationAlpha: BlendFactorOneMinusSourceAlpha,
|
||||
BlendOperationColor: BlendOperationAdd,
|
||||
BlendOperationRGB: BlendOperationAdd,
|
||||
BlendOperationAlpha: BlendOperationAdd,
|
||||
}
|
||||
|
||||
// Sum of source and destination (a.k.a. 'plus' or 'additive')
|
||||
// c_out = c_src + c_dst
|
||||
BlendLighter = Blend{
|
||||
BlendFactorSourceColor: BlendFactorOne,
|
||||
BlendFactorSourceRGB: BlendFactorOne,
|
||||
BlendFactorSourceAlpha: BlendFactorOne,
|
||||
BlendFactorDestinationColor: BlendFactorOne,
|
||||
BlendFactorDestinationRGB: BlendFactorOne,
|
||||
BlendFactorDestinationAlpha: BlendFactorOne,
|
||||
BlendOperationColor: BlendOperationAdd,
|
||||
BlendOperationRGB: BlendOperationAdd,
|
||||
BlendOperationAlpha: BlendOperationAdd,
|
||||
}
|
||||
)
|
||||
|
10
graphics.go
10
graphics.go
@ -80,7 +80,7 @@ const (
|
||||
// Deprecated: as of v2.5. Use BlendLighter instead.
|
||||
CompositeModeLighter
|
||||
|
||||
// Deprecated: as of v2.5. Use Blend with BlendFactorDestinationColor and BlendFactorZero instead.
|
||||
// Deprecated: as of v2.5. Use Blend with BlendFactorDestinationRGB and BlendFactorZero instead.
|
||||
CompositeModeMultiply
|
||||
)
|
||||
|
||||
@ -114,11 +114,11 @@ func (c CompositeMode) blend() Blend {
|
||||
return BlendLighter
|
||||
case CompositeModeMultiply:
|
||||
return Blend{
|
||||
BlendFactorSourceColor: BlendFactorDestinationColor,
|
||||
BlendFactorSourceAlpha: BlendFactorDestinationColor,
|
||||
BlendFactorDestinationColor: BlendFactorZero,
|
||||
BlendFactorSourceRGB: BlendFactorDestinationRGB,
|
||||
BlendFactorSourceAlpha: BlendFactorDestinationRGB,
|
||||
BlendFactorDestinationRGB: BlendFactorZero,
|
||||
BlendFactorDestinationAlpha: BlendFactorZero,
|
||||
BlendOperationColor: BlendOperationAdd,
|
||||
BlendOperationRGB: BlendOperationAdd,
|
||||
BlendOperationAlpha: BlendOperationAdd,
|
||||
}
|
||||
default:
|
||||
|
@ -3607,11 +3607,11 @@ func TestImageBlendOperation(t *testing.T) {
|
||||
dst.WritePixels(dstPix)
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
op.Blend = ebiten.Blend{
|
||||
BlendFactorSourceColor: ebiten.BlendFactorOne,
|
||||
BlendFactorSourceRGB: ebiten.BlendFactorOne,
|
||||
BlendFactorSourceAlpha: ebiten.BlendFactorOne,
|
||||
BlendFactorDestinationColor: ebiten.BlendFactorOne,
|
||||
BlendFactorDestinationRGB: ebiten.BlendFactorOne,
|
||||
BlendFactorDestinationAlpha: ebiten.BlendFactorOne,
|
||||
BlendOperationColor: cop,
|
||||
BlendOperationRGB: cop,
|
||||
BlendOperationAlpha: aop,
|
||||
}
|
||||
dst.DrawImage(src, op)
|
||||
|
@ -277,11 +277,11 @@ type drawTrianglesCommand struct {
|
||||
func (c *drawTrianglesCommand) String() string {
|
||||
// TODO: Improve readability
|
||||
blend := fmt.Sprintf("{src-color: %d, src-alpha: %d, dst-color: %d, dst-alpha: %d, op-color: %d, op-alpha: %d}",
|
||||
c.blend.BlendFactorSourceColor,
|
||||
c.blend.BlendFactorSourceRGB,
|
||||
c.blend.BlendFactorSourceAlpha,
|
||||
c.blend.BlendFactorDestinationColor,
|
||||
c.blend.BlendFactorDestinationRGB,
|
||||
c.blend.BlendFactorDestinationAlpha,
|
||||
c.blend.BlendOperationColor,
|
||||
c.blend.BlendOperationRGB,
|
||||
c.blend.BlendOperationAlpha)
|
||||
|
||||
dst := fmt.Sprintf("%d", c.dst.id)
|
||||
|
@ -15,11 +15,11 @@
|
||||
package graphicsdriver
|
||||
|
||||
type Blend struct {
|
||||
BlendFactorSourceColor BlendFactor
|
||||
BlendFactorSourceRGB BlendFactor
|
||||
BlendFactorSourceAlpha BlendFactor
|
||||
BlendFactorDestinationColor BlendFactor
|
||||
BlendFactorDestinationRGB BlendFactor
|
||||
BlendFactorDestinationAlpha BlendFactor
|
||||
BlendOperationColor BlendOperation
|
||||
BlendOperationRGB BlendOperation
|
||||
BlendOperationAlpha BlendOperation
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ const (
|
||||
BlendFactorDestinationAlpha
|
||||
BlendFactorOneMinusSourceAlpha
|
||||
BlendFactorOneMinusDestinationAlpha
|
||||
BlendFactorDestinationColor
|
||||
BlendFactorDestinationRGB
|
||||
)
|
||||
|
||||
type BlendOperation byte
|
||||
@ -44,28 +44,28 @@ const (
|
||||
)
|
||||
|
||||
var BlendSourceOver = Blend{
|
||||
BlendFactorSourceColor: BlendFactorOne,
|
||||
BlendFactorSourceRGB: BlendFactorOne,
|
||||
BlendFactorSourceAlpha: BlendFactorOne,
|
||||
BlendFactorDestinationColor: BlendFactorOneMinusSourceAlpha,
|
||||
BlendFactorDestinationRGB: BlendFactorOneMinusSourceAlpha,
|
||||
BlendFactorDestinationAlpha: BlendFactorOneMinusSourceAlpha,
|
||||
BlendOperationColor: BlendOperationAdd,
|
||||
BlendOperationRGB: BlendOperationAdd,
|
||||
BlendOperationAlpha: BlendOperationAdd,
|
||||
}
|
||||
|
||||
var BlendClear = Blend{
|
||||
BlendFactorSourceColor: BlendFactorZero,
|
||||
BlendFactorSourceRGB: BlendFactorZero,
|
||||
BlendFactorSourceAlpha: BlendFactorZero,
|
||||
BlendFactorDestinationColor: BlendFactorZero,
|
||||
BlendFactorDestinationRGB: BlendFactorZero,
|
||||
BlendFactorDestinationAlpha: BlendFactorZero,
|
||||
BlendOperationColor: BlendOperationAdd,
|
||||
BlendOperationRGB: BlendOperationAdd,
|
||||
BlendOperationAlpha: BlendOperationAdd,
|
||||
}
|
||||
|
||||
var BlendCopy = Blend{
|
||||
BlendFactorSourceColor: BlendFactorOne,
|
||||
BlendFactorSourceRGB: BlendFactorOne,
|
||||
BlendFactorSourceAlpha: BlendFactorOne,
|
||||
BlendFactorDestinationColor: BlendFactorZero,
|
||||
BlendFactorDestinationRGB: BlendFactorZero,
|
||||
BlendFactorDestinationAlpha: BlendFactorZero,
|
||||
BlendOperationColor: BlendOperationAdd,
|
||||
BlendOperationRGB: BlendOperationAdd,
|
||||
BlendOperationAlpha: BlendOperationAdd,
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ func blendFactorToBlend(f graphicsdriver.BlendFactor, alpha bool) _D3D12_BLEND {
|
||||
return _D3D12_BLEND_INV_SRC_ALPHA
|
||||
case graphicsdriver.BlendFactorOneMinusDestinationAlpha:
|
||||
return _D3D12_BLEND_INV_DEST_ALPHA
|
||||
case graphicsdriver.BlendFactorDestinationColor:
|
||||
case graphicsdriver.BlendFactorDestinationRGB:
|
||||
// D3D12_RENDER_TARGET_BLEND_DESC's *BlendAlpha members don't allow *_COLOR values.
|
||||
// See https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_render_target_blend_desc.
|
||||
if alpha {
|
||||
@ -423,9 +423,9 @@ func (p *pipelineStates) newPipelineState(device *_ID3D12Device, vsh, psh *_ID3D
|
||||
{
|
||||
BlendEnable: 1,
|
||||
LogicOpEnable: 0,
|
||||
SrcBlend: blendFactorToBlend(blend.BlendFactorSourceColor, false),
|
||||
DestBlend: blendFactorToBlend(blend.BlendFactorDestinationColor, false),
|
||||
BlendOp: blendOperationToBlendOp(blend.BlendOperationColor),
|
||||
SrcBlend: blendFactorToBlend(blend.BlendFactorSourceRGB, false),
|
||||
DestBlend: blendFactorToBlend(blend.BlendFactorDestinationRGB, false),
|
||||
BlendOp: blendOperationToBlendOp(blend.BlendOperationRGB),
|
||||
SrcBlendAlpha: blendFactorToBlend(blend.BlendFactorSourceAlpha, true),
|
||||
DestBlendAlpha: blendFactorToBlend(blend.BlendFactorDestinationAlpha, true),
|
||||
BlendOpAlpha: blendOperationToBlendOp(blend.BlendOperationAlpha),
|
||||
|
@ -314,8 +314,8 @@ func blendFactorToMetalBlendFactor(c graphicsdriver.BlendFactor) mtl.BlendFactor
|
||||
return mtl.BlendFactorOneMinusSourceAlpha
|
||||
case graphicsdriver.BlendFactorOneMinusDestinationAlpha:
|
||||
return mtl.BlendFactorOneMinusDestinationAlpha
|
||||
case graphicsdriver.BlendFactorDestinationColor:
|
||||
return mtl.BlendFactorDestinationColor
|
||||
case graphicsdriver.BlendFactorDestinationRGB:
|
||||
return mtl.BlendFactorDestinationRGB
|
||||
default:
|
||||
panic(fmt.Sprintf("metal: invalid blend factor: %d", c))
|
||||
}
|
||||
|
@ -271,11 +271,11 @@ type BlendFactor uint8
|
||||
const (
|
||||
BlendFactorZero BlendFactor = 0
|
||||
BlendFactorOne BlendFactor = 1
|
||||
BlendFactorSourceColor BlendFactor = 2
|
||||
BlendFactorSourceRGB BlendFactor = 2
|
||||
BlendFactorOneMinusSourceColor BlendFactor = 3
|
||||
BlendFactorSourceAlpha BlendFactor = 4
|
||||
BlendFactorOneMinusSourceAlpha BlendFactor = 5
|
||||
BlendFactorDestinationColor BlendFactor = 6
|
||||
BlendFactorDestinationRGB BlendFactor = 6
|
||||
BlendFactorOneMinusDestinationColor BlendFactor = 7
|
||||
BlendFactorDestinationAlpha BlendFactor = 8
|
||||
BlendFactorOneMinusDestinationAlpha BlendFactor = 9
|
||||
|
@ -113,11 +113,11 @@ func (s *Shader) RenderPipelineState(view *view, blend graphicsdriver.Blend, ste
|
||||
rpld.ColorAttachments[0].BlendingEnabled = true
|
||||
|
||||
rpld.ColorAttachments[0].DestinationAlphaBlendFactor = blendFactorToMetalBlendFactor(blend.BlendFactorDestinationAlpha)
|
||||
rpld.ColorAttachments[0].DestinationRGBBlendFactor = blendFactorToMetalBlendFactor(blend.BlendFactorDestinationColor)
|
||||
rpld.ColorAttachments[0].DestinationRGBBlendFactor = blendFactorToMetalBlendFactor(blend.BlendFactorDestinationRGB)
|
||||
rpld.ColorAttachments[0].SourceAlphaBlendFactor = blendFactorToMetalBlendFactor(blend.BlendFactorSourceAlpha)
|
||||
rpld.ColorAttachments[0].SourceRGBBlendFactor = blendFactorToMetalBlendFactor(blend.BlendFactorSourceColor)
|
||||
rpld.ColorAttachments[0].SourceRGBBlendFactor = blendFactorToMetalBlendFactor(blend.BlendFactorSourceRGB)
|
||||
rpld.ColorAttachments[0].AlphaBlendOperation = blendOperationToMetalBlendOperation(blend.BlendOperationAlpha)
|
||||
rpld.ColorAttachments[0].RGBBlendOperation = blendOperationToMetalBlendOperation(blend.BlendOperationColor)
|
||||
rpld.ColorAttachments[0].RGBBlendOperation = blendOperationToMetalBlendOperation(blend.BlendOperationRGB)
|
||||
|
||||
if stencilMode == prepareStencil {
|
||||
rpld.ColorAttachments[0].WriteMask = mtl.ColorWriteMaskNone
|
||||
|
@ -55,7 +55,7 @@ func convertBlendFactor(f graphicsdriver.BlendFactor) blendFactor {
|
||||
return glOneMinusSrcAlpha
|
||||
case graphicsdriver.BlendFactorOneMinusDestinationAlpha:
|
||||
return glOneMinusDstAlpha
|
||||
case graphicsdriver.BlendFactorDestinationColor:
|
||||
case graphicsdriver.BlendFactorDestinationRGB:
|
||||
return glDstColor
|
||||
default:
|
||||
panic(fmt.Sprintf("opengl: invalid blend factor %d", f))
|
||||
|
@ -119,13 +119,13 @@ func (c *context) blend(blend graphicsdriver.Blend) {
|
||||
}
|
||||
c.lastBlend = blend
|
||||
gl.BlendFuncSeparate(
|
||||
uint32(convertBlendFactor(blend.BlendFactorSourceColor)),
|
||||
uint32(convertBlendFactor(blend.BlendFactorDestinationColor)),
|
||||
uint32(convertBlendFactor(blend.BlendFactorSourceRGB)),
|
||||
uint32(convertBlendFactor(blend.BlendFactorDestinationRGB)),
|
||||
uint32(convertBlendFactor(blend.BlendFactorSourceAlpha)),
|
||||
uint32(convertBlendFactor(blend.BlendFactorDestinationAlpha)),
|
||||
)
|
||||
gl.BlendEquationSeparate(
|
||||
uint32(convertBlendOperation(blend.BlendOperationColor)),
|
||||
uint32(convertBlendOperation(blend.BlendOperationRGB)),
|
||||
uint32(convertBlendOperation(blend.BlendOperationAlpha)),
|
||||
)
|
||||
}
|
||||
|
@ -109,13 +109,13 @@ func (c *context) blend(blend graphicsdriver.Blend) {
|
||||
return
|
||||
}
|
||||
c.ctx.BlendFuncSeparate(
|
||||
uint32(convertBlendFactor(blend.BlendFactorSourceColor)),
|
||||
uint32(convertBlendFactor(blend.BlendFactorDestinationColor)),
|
||||
uint32(convertBlendFactor(blend.BlendFactorSourceRGB)),
|
||||
uint32(convertBlendFactor(blend.BlendFactorDestinationRGB)),
|
||||
uint32(convertBlendFactor(blend.BlendFactorSourceAlpha)),
|
||||
uint32(convertBlendFactor(blend.BlendFactorDestinationAlpha)),
|
||||
)
|
||||
c.ctx.BlendEquationSeparate(
|
||||
uint32(convertBlendOperation(blend.BlendOperationColor)),
|
||||
uint32(convertBlendOperation(blend.BlendOperationRGB)),
|
||||
uint32(convertBlendOperation(blend.BlendOperationAlpha)),
|
||||
)
|
||||
}
|
||||
|
@ -192,13 +192,13 @@ func (c *context) blend(blend graphicsdriver.Blend) {
|
||||
c.lastBlend = blend
|
||||
gl := c.gl
|
||||
gl.blendFuncSeparate.Invoke(
|
||||
int(convertBlendFactor(blend.BlendFactorSourceColor)),
|
||||
int(convertBlendFactor(blend.BlendFactorDestinationColor)),
|
||||
int(convertBlendFactor(blend.BlendFactorSourceRGB)),
|
||||
int(convertBlendFactor(blend.BlendFactorDestinationRGB)),
|
||||
int(convertBlendFactor(blend.BlendFactorSourceAlpha)),
|
||||
int(convertBlendFactor(blend.BlendFactorDestinationAlpha)),
|
||||
)
|
||||
gl.blendEquationSeparate.Invoke(
|
||||
int(convertBlendOperation(blend.BlendOperationColor)),
|
||||
int(convertBlendOperation(blend.BlendOperationRGB)),
|
||||
int(convertBlendOperation(blend.BlendOperationAlpha)),
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user