• P

    Can you make me a quick example please? I can't find any online documentation about how it works, no more than
    "pipeline.getTextureUnit();, you have put a string between the parenthesis"

    posted in Kode read more
  • P

    I beg your pardon, may I request your help again? (I know, it's been a while since I posted this, I didn't know how to do it and I've been busy lately but today I gave it a shot and finally I've figured some basic stuff out.)

    I'm stuck on the second texture step.

    Here's my ImageObject.hx (The whole pipeline set-up is in Project.hx but I don't think it's necessary to show it)

    import kha.Assets;
    import kha.graphics2.Graphics;
    import kha.Color;
    import kha.Image;
    import Entity;
    class ImageObject extends Entity{
    	public var image:Image;
    	//public var mask:Image; ?
    	public function new(image:Image,x:Float, y:Float, width:Int, height: Int){
    	this.image = image;
    	super(x, y, width, height);
    public function update(){
    public function render(graphics:Graphics){
    		//graphics.color = Color.Green;
    		graphics.pipeline = Project.pipeline;
    		//Dibujar imagen!!! Se divide X entre 2 para centrarlo con el raton, al igual que con Y
    		graphics.drawScaledImage(image,x - width / 2, y,width * 1.1, height * 1.1);

    And the fragment shader:

    #version 450
    uniform sampler2D tex;
    uniform sampler2D mask;
    in vec2 texCoord;
    in vec4 color;
    out vec4 FragColor;
    void main() {
    	vec4 texcolor = texture(tex, texCoord) * color;
    	texcolor.rgb *= color.a;
    	texcolor.rgb = texcolor.bgr; // swap color channels
    	if(texture(mask, texCoord).a != 1.0f)
       FragColor = texture(tex, texCoord);

    Ok, I have Image, which is my diffuse texture, but now I'm stuck doing the mask. What do I have to do to make the shader recognize a 2nd texture and set is as "uniform sampler2D mask;"?
    PD: The shader itself is working (Colors channels do get swapped)

    posted in Kode read more
  • P

    (Quick example image I just made)

    I'm making a simple android game with kha and I need to apply an opacity mask, so I just have 1 opacity texture and I reuse it across a lot of diffuse textures instead of making a lot of .png files with the opacity included them. I want to know if this is possible, and how to do it. Thanks.

    posted in Kode read more