• J
    JohnSword

    well, it must be something very simple but I simply don't understand how I would apply a filter after another thus combining the effects. This is the code I have:

    package;

    import kha.Framebuffer;
    import kha.Font;
    import kha.Scheduler;
    import kha.System;
    import kha.Assets;
    ///we just import Framebuffer & Color. we use Framebuffer to make sure we are
    import kha.Framebuffer;
    import kha.Color;
    ///we will be using the FastMatrix for positioning in the middle-ish of the screen
    import kha.math.FastMatrix3;
    import kha.Canvas;

    import kha.Color;
    import kha.Image;
    import kha.Scaler;
    import kha.Scheduler;
    import kha.Shaders;
    import kha.System;
    import kha.graphics4.PipelineState;
    import kha.graphics4.VertexData;
    import kha.graphics4.VertexStructure;

    import playground.TestbedModel;
    import playground.TestbedController;

    import filters.BlobFilter;
    import filters.EmbossFilter;
    import filters.Filter;

    import haxe.ds.Vector;

    class Project {

    private var m_world : World;
    private var m_debugdraw : HxDebugDraw;
    public var controller:TestbedController;
    private var backbuffer: Image;
    private var pipeline: PipelineState;
    private var pipeline2: PipelineState;
    
    public function new() {
    	Assets.loadEverything(loadAll);
    
    	System.notifyOnRender(render);
    	Scheduler.addTimeTask(update, 0, 1 / 60);
    
    	backbuffer = Image.createRenderTarget(1024, 768);
    	pipeline = createPipeline();
    	pipeline2 = createPipeline2();
    
    	fps = new FPS();
    
    	m_debugdraw = new HxDebugDraw(true);
    	var model : TestbedModel = new TestbedModel();
    	model.setDebugDraw(m_debugdraw);
    
    	controller = new TestbedController(model, UpdateBehavior.UPDATE_CALLED, MouseBehavior.NORMAL);
    	controller.updateExtents(1024 / 2, 768 / 2);
    	
    	// the array of tests to load is in the TestbedModel class
    	controller.playTest(22);
    	controller.start();
    }
    
    public function loadAll() {
    	font01 = Assets.fonts.champagneLimousines;
    	System.notifyOnRender(render);
    }
    
    function update(): Void {
    }
    
    function createPipeline(): PipelineState {
    	var pipeline = new PipelineState();
    	var structure = new VertexStructure();
    	structure.add("vertexPosition", VertexData.Float3);
    	structure.add("texPosition", VertexData.Float2);
    	structure.add("vertexColor", VertexData.Float4);
    	pipeline.inputLayout = [structure];
    	pipeline.vertexShader = Shaders.painter_image_vert;
    	pipeline.fragmentShader = Shaders.blob_frag; // first filter
    	pipeline.compile();
    	return pipeline;
    }
    
    function createPipeline2(): PipelineState {
    	var pipeline = new PipelineState();
    	var structure = new VertexStructure();
    	structure.add("vertexPosition", VertexData.Float3);
    	structure.add("texPosition", VertexData.Float2);
    	structure.add("vertexColor", VertexData.Float4);
    	pipeline.inputLayout = [structure];
    	pipeline.vertexShader = Shaders.painter_image_vert;
    	pipeline.fragmentShader = Shaders.emboss_frag; // second filter to  be applied over the first one
    	pipeline.compile();
    	return pipeline;
    }
    
    function render(framebuffer: Framebuffer): Void {
    	var g = backbuffer.g2;
    	g.begin(true, Color.Black);
    	g.color = Color.Red;
    	g.fillRect(0, 100, 500, 500);
    	g.end();
    
                // draw physics into image buffer
    	m_debugdraw.m_framebuffer = g;
    	g.begin(false);
    	controller.stepAndRender();
    	g.end();
    
    	g = framebuffer.g2;
    	g.begin();
    	g.pipeline = pipeline; // applies one or the other filter but how to apply one after the other?
    	Scaler.scale(backbuffer, framebuffer, System.screenRotation);
    	g.end();
    
    	// g.begin();
    	// g.pipeline = pipeline;
    	// Scaler.scale(backbuffer, framebuffer, System.screenRotation);
    	// g.end();
    
    	// g.begin(false);
    	// g.pipeline = pipeline2;
    	// Scaler.scale(backbuffer, framebuffer, System.screenRotation);
    	// g.end();
    }
    

    }

    posted in Kode read more
  • J
    JohnSword

    Does that Krom error happen on any project?
    I created a barebones project using init kha, set a breakpoint in the Project class the tried to debug by running with the krom target. First I get a popup asking if I want to allow the app to accept incoming connections, then if I press allow the app doesn't stop in the breakpoint even though it runs and even prints traces. But when I close the app it gives a "has closed unexpectedly" error message.

    What macOS version is that?
    El Capitan v10.11.6

    Is that using the integrated Kha version?
    Yes.

    Regarding the multiple shaders, do you have an example of how to use multiple render targets?

    posted in Kode read more
  • J
    JohnSword

    I got another question regarding shaders. I want to transform a scene (the screen rendered into an image) several times, for example: first apply a blur filter, then a threshold filter and finally an emboss filter. So, is it possible to stack shaders on top of shaders? How would that work?

    posted in Kode read more
  • J
    JohnSword

    I see the target for krom in kodestudio but when I do the start debugging it doesn't run. It crashes before opening the program window and throws a bunch of errors into the console:

    Creating Kha project.
    Error processing "evaluate": TypeError: Cannot read property 'api' of undefined
    at ChromeConnection.get api [as api] (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeConnection.js:56:28)
    at ChromeDebugAdapter.get chrome [as chrome] (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeDebugAdapter.js:40:38)
    at ChromeDebugAdapter.globalEvaluate (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeDebugAdapter.js:1021:20)
    at ChromeDebugAdapter.evaluate (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeDebugAdapter.js:943:32)
    at dispatchRequest (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeDebugSession.js:122:68)
    at ProtocolServer._handleData (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-debugadapter/lib/protocol.js:104:38)
    at Socket.<anonymous> (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-debugadapter/lib/protocol.js:24:60)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    [...]
    Error processing "evaluate": TypeError: Cannot read property 'api' of undefined
    at ChromeConnection.get api [as api] (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeConnection.js:56:28)
    at ChromeDebugAdapter.get chrome [as chrome] (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeDebugAdapter.js:40:38)
    at ChromeDebugAdapter.globalEvaluate (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeDebugAdapter.js:1021:20)
    at ChromeDebugAdapter.evaluate (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeDebugAdapter.js:943:32)
    at dispatchRequest (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeDebugSession.js:122:68)
    at ProtocolServer._handleData (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-debugadapter/lib/protocol.js:104:38)
    at Socket.<anonymous> (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-debugadapter/lib/protocol.js:24:60)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    [...]
    Error processing "evaluate": TypeError: Cannot read property 'api' of undefined
    at ChromeConnection.get api [as api] (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeConnection.js:56:28)
    at ChromeDebugAdapter.get chrome [as chrome] (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeDebugAdapter.js:40:38)
    at ChromeDebugAdapter.globalEvaluate (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeDebugAdapter.js:1021:20)
    at ChromeDebugAdapter.evaluate (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeDebugAdapter.js:943:32)
    at dispatchRequest (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeDebugSession.js:122:68)
    at ProtocolServer._handleData (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-debugadapter/lib/protocol.js:104:38)
    at Socket.<anonymous> (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-debugadapter/lib/protocol.js:24:60)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    [...]
    Error processing "evaluate": TypeError: Cannot read property 'api' of undefined
    at ChromeConnection.get api [as api] (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeConnection.js:56:28)
    at ChromeDebugAdapter.get chrome [as chrome] (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeDebugAdapter.js:40:38)
    at ChromeDebugAdapter.globalEvaluate (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeDebugAdapter.js:1021:20)
    at ChromeDebugAdapter.evaluate (/Users/john/Desktop/Kode Studio.app/Contents/Resources/app/extensions/krom-debug/node_modules/vscode-chrome-debug-core/out/src/chrome/chromeDebugAdapter.js:943:32)

    ******** Unhandled error in debug adapter - Unhandled promise rejection: {"id":2010,"format":"Cannot connect to runtime process, timeout after {_timeout} ms - (reason: {_error}).","variables":{"_error":"Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:10212","_timeout":"10000"}}

    posted in Kode read more
  • J
    JohnSword

    ok more questions. I saw your presentation at WWX2016 that you were able to debug shaders somehow in Kode IDE. Is that feature already supported in 17.1 version, if so how do I get that working? Also, I'm not able to debug or run using Krom (I'm using MacOSX El Capitan 10.11.6), is that feature also implemented?

    thanks.

    posted in Kode read more
  • J
    JohnSword

    it works, thanks Robert.
    One other question, is there any difference between rendering with a Framebuffer or rendering with Canvas?

    posted in Kode read more
  • J
    JohnSword

    I mean I want to apply a shader to framebuffer.g2 where stuff has already been drawn into, I have a bunch of particles drawn and want to apply a blur effect to them. How does this process work in kha? Do I need to draw to an image then apply the shader to the image?
    Are examples of this somewhere?

    posted in Kode read more

Looks like your connection to Kode Forum was lost, please wait while we try to reconnect.