blendmodes - mojo2

Rich

Active Member
3rd Party Module Dev
Joined
Sep 9, 2017
Hi
i may need some help please.. is there a blendmode (or other method) that will allow me to And the below pictures together to make image 3?
(forget the white ghosting in image 3, its supposed to all blue like in image 2, I'll ust being lazy when creating the picture)
 

Attachments

Last edited:

magic

Active Member
3rd Party Module Dev
3rd Party Tool Dev
Joined
Mar 5, 2018
Try holzchopf overlay shaders. I'm not sure about that but you can check out yourself here:
 

PixelPaladin

Active Member
CX Code Contributor
3rd Party Module Dev
Joined
Aug 27, 2017
Location
Germany
If the second image is just a rectangle you could simply set your color and draw the image via DrawRect(x,y,image,sourceX,sourceY,width,height) or set a clipping rectangle. If the second image could be any image you should use a shader.
 

Rich

Active Member
3rd Party Module Dev
Joined
Sep 9, 2017
thanks for all the pointers everyone...
I decided to write a quick app to show me which one I need... Im leaning towards AlphaStamp
Cerberus X:
Strict
Import mojo2

Class myClass Extends App
    Field canvas:Canvas
    Field blend:Int=0
    Field mask_img:Image, pic_img:Image
    Field dest_img:Image,dest_cnvs:Canvas

    Method OnCreate:Int()
        mask_img = Image.Load("mask.png")
        pic_img = Image.Load("pic.png")
        
        dest_img = New Image(200,200)
        dest_cnvs = New Canvas(dest_img)
        
        SetUpdateRate(60)                
        canvas = New Canvas
        Return 0
    End
    
    Method OnUpdate:Int()
        If KeyHit(KEY_SPACE) Or MouseHit(MOUSE_LEFT) Then blend=(blend+1) Mod 16
        Return 0
    End
    
    Method OnRender:Int()
        dest_cnvs.Clear(0,0,0,0)
        If blend<8
            dest_cnvs.SetBlendMode BlendMode.Alpha
            dest_cnvs.DrawImage mask_img,100,100
            dest_cnvs.SetBlendMode blend
            dest_cnvs.DrawImage pic_img,100,100
        Else
            dest_cnvs.SetBlendMode BlendMode.Alpha
            dest_cnvs.DrawImage pic_img,100,100
            dest_cnvs.SetBlendMode blend-8
            dest_cnvs.DrawImage mask_img,100,100
        End
        dest_cnvs.Flush()
        
        canvas.Clear (0,0.5,0)    
        canvas.SetBlendMode BlendMode.Alpha
        If blend<8
            canvas.DrawText "BlendMode."+blendmode(blend),0,0
            canvas.DrawImage mask_img,100,200                            
            canvas.DrawImage pic_img,300,200                            
            canvas.DrawImage dest_img,500,200                            
        Else
            canvas.DrawText "BlendMode."+blendmode(blend-8),0,0
            canvas.DrawImage pic_img,100,200                            
            canvas.DrawImage mask_img,300,200                            
            canvas.DrawImage dest_img,500,200                            
        End
        canvas.DrawText "+",200,200
        canvas.DrawText "=",400,200
        canvas.Flush

        Return 0
    End
    
    Method blendmode:String(mode:Int)
        Select mode
        Case 0
            Return "Opaque"
        Case 1
            Return "Alpha"
        Case 2
            Return "Additive"
        Case 3
            Return "Multiply"
        Case 4
            Return "Multiply2"
        Case 5
            Return "Alpha2"
        Case 6
            Return "Opaque2"
        Case 7
            Return "AlphaStamp"
        End
        Return "no blend mode"
     End
End

Function Main:Int()
    New myClass        
    Return 0
End
obv use you own images or use mine....
 

Attachments

Last edited:

Rich

Active Member
3rd Party Module Dev
Joined
Sep 9, 2017
@Holzchopf it was Multiply2 in the end
the above example helped me prove which mode i wanted, which lead me to discover a bug in my app code ;-)
 
Top Bottom