• W

    Hallo Robert, i have upload to github
    uname -a:
    Linux twist 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u6 (2018-10-08) x86_64 GNU/Linux
    clang --version:
    clang version 7.0.0-svn345401-1~exp1~20181026173536.34 (branches/release_70)
    node <path to kore>/make.js --compile
    node <path to kore>/make.js --onlyshaders
    I use the latest kore version, but it should work, all the gametech-examples (with G4) compile and run without any errors (with very small change - third parameter from VertexBuffer has a default and is no more int)
    I can validate the shaders with glslangValidator without errors. But i am not sure about the pch.h. I have tried everything without success...

    posted in Kode read more
  • W

    hi, i use the Empty project from Kore and would have some uniforms in the fragment shader.
    I put a vec2 variable in the shader.frag.glsl:
    uniform vec2 iMouse;
    Add a line in the kore function of the Shader.cpp after pipeline->compile():
    mousePos = pipeline->getConstantLocation("iMouse");
    And after Graphics4::setPipeline(pipeline) in the update function add a line:
    Graphics4::setFloat2(mousePos, (float)mouseX, (float)mouseY);
    I get always this error message:
    Uniform iMouse not found.

    The program compile without errors, mouseX and mouseY are valid integers and mousePos is a Graphics4::ConstantLocation.
    Hope for help after hours with trial and error.

    posted in Kode read more
  • W

    hello romamik ,

    first many thanks for the zui update.
    After removing one of the System.notifyOnRender calls the model appears again, no matter if i call g2.begin(false) or not. I am happy, but not too long.
    I have a class which splits a icosahedron for me. Now I wanted to test the performance of my video card. After 33 splits (one face of the icosahedron ), these are only 23120 triangles for the entire model, i get a strange result.

    (file:///bla/bla/do not know how i can upload files/Bildschirmfoto%20vom%202016-09-24%2021-06-50.png)

    That could not be, and I thought that is due to the javascript float type (or what ever). I test my program with the cpp target and now the model disappears again. After removing the g2 render calls from zui, the model is drawn and i can go up to 230 splits ca. 1,2 million triangles without the ugly hole in my sphere. Now a simple example with zui and graphics4.

    private var vertices:Array<Float> = [
        0, Math.sqrt(3) / 2, 0,
        -0.5, 0, -1 / 3,
        0.5, 0, -1 / 3,
        0, 0, -1 / 3 + Math.sqrt(3) / 2,
        0, -Math.sqrt(3) / 2, 0];
    private var colors:Array<Float> = [
        1, 1, 0,
        0, 1, 0,
        0, 0, 1,
        1, 0, 0,
        1, 0, 1];
    private var indices:Array<Int> = [
        0, 1, 2,
        0, 2, 3,
        0, 3, 1,
        4, 2, 1,
        4, 3, 2,
        4, 1, 3];
    private var font:Font;
    private var structure:VertexStructure;
    private var structureLength:Int;
    private var vertexBuffer:VertexBuffer;
    private var indexBuffer:IndexBuffer;
    private var pipeline:PipelineState;
    private var mvpID:ConstantLocation;
    private var projection:FastMatrix4 = FastMatrix4.perspectiveProjection(45.0, 4.0 / 3.0, 0.1, 100.0);
    private var view:FastMatrix4 = FastMatrix4.lookAt(
        new FastVector3(2, 0, 0), // Camera is at (2, 0, 0), in World Space
        new FastVector3(0, 0, 0), // and looks at the origin
        new FastVector3(0, 1, 0)); // Head is up (set to (0, -1, 0) to look upside-down)
    private var model:FastMatrix4 = FastMatrix4.identity();
    private var mvp:FastMatrix4;
    private var lastTime:Float;
    private var rotX:Float = 0;
    private var rotY:Float = 0;
    private var rotZ:Float = 0;
    private var ui:Zui;
    private var width:Int;
    private var height:Int;
    private function loadingFinish():Void {
        font = Assets.fonts.DroidSans;
        ui = new Zui(font);
        // Define vertex structure
        structure = new VertexStructure();
        structure.add("pos", VertexData.Float3);
        structure.add("col", VertexData.Float3);
        structureLength = 6;
        // Compile pipeline state
        pipeline = new PipelineState();
        pipeline.inputLayout = [structure];
        pipeline.vertexShader = Shaders.simple_vert;
        pipeline.fragmentShader = Shaders.simple_frag;
        // Set depth mode
        pipeline.depthWrite = true;
        pipeline.depthMode = CompareMode.Less;
        pipeline.cullMode = CullMode.CounterClockwise;
        // Get a handle for our "MVP" uniform
        mvpID = pipeline.getConstantLocation("MVP");
        mvp = FastMatrix4.identity();
        mvp = mvp.multmat(projection);
        mvp = mvp.multmat(view);
        mvp = mvp.multmat(model);
        vertexBuffer = new VertexBuffer(
            /* Vertex count - 5 vertices * 6 floats */ 30,
            /* Vertex structure */ structure,
            /* Vertex data will stay the same */ Usage.StaticUsage);
        var vbData = vertexBuffer.lock();
        for (i in 0...Std.int(vbData.length / structureLength)) {
            vbData.set(i * structureLength, vertices[i * 3]);
            vbData.set(i * structureLength + 1, vertices[i * 3 + 1]);
            vbData.set(i * structureLength + 2, vertices[i * 3 + 2]);
            vbData.set(i * structureLength + 3, colors[i * 3]);
            vbData.set(i * structureLength + 4, colors[i * 3 + 1]);
            vbData.set(i * structureLength + 5, colors[i * 3 + 2]);
        // Create index buffer
        indexBuffer = new IndexBuffer(
            /* Number of indices for tetraeder */ indices.length,
            /* Index data will stay the same*/ Usage.StaticUsage);
        // Copy indices to index buffer
        var iData = indexBuffer.lock();
        for (i in 0...iData.length) {
            iData[i] = indices[i];
        width = System.windowWidth();
        height = System.windowHeight();
        lastTime = 0;
        Scheduler.addTimeTask(update, 0, 1 / 60);
    public function new() {
    public function update():Void {
        model = FastMatrix4.rotation(rotY, rotX, rotZ);
        mvp = FastMatrix4.identity();
        mvp = mvp.multmat(projection);
        mvp = mvp.multmat(view);
        mvp = mvp.multmat(model);
    public function render(framebuffer:Framebuffer):Void {
        var g = framebuffer.g4;
        g.clear(Color.fromFloats(0.05, 0.0, 0.15), 1.0);
        g.setMatrix(mvpID, mvp);
        var g2 = framebuffer.g2; // g2.begin(false);
        if (ui.window("", 0, 0, width, height)) {
            if (ui.node(Id.node(), "Rotations", true)) {
                ui.row([1/3, 1/3, 1/3]);
                rotX = ui.slider(Id.slider(), "X", -Math.PI, Math.PI);
                rotY = ui.slider(Id.slider(), "Y", -Math.PI, Math.PI);
                rotZ = ui.slider(Id.slider(), "Z", -Math.PI, Math.PI);
        ui.end(); //g2.end();

    It works with the html target, but the cpp target does not show the model.
    It flickers a little bit if i move the sliders. Maybe it's because of my onboard Intel graphics card, but in fact I have no idea what's wrong.

    posted in Kode read more
  • W

    Hi lubos,
    thanks for the links.
    But befor i dares to bullet stuff, I want to understand the capabilities of verletkha.
    That is enough funny physic stuff for the first time.
    But surfing from your link, I found this tutorial:
    Jamie King
    and the git repo
    Since I have fast internet, i like youtube. And this guy is really entertaining.
    Best wishes

    posted in Kode read more
  • W

    Hallo lubos,
    shame on me, i never touch my Main.hx:

    public static function main() {
    	System.init({title:"Sphere", width:800, height:600}, function(){
    			var game = new LookAtCam();
    			Scheduler.addTimeTask(game.update, 0, 1 / 60);

    And then copy and paste your tutorial, but there is always a System.notifyOnRender call in your code. Remove one of these calls and everything runs smoothly.

    I have one more question, specially to you. I know that your day has also only 24 hours, but can you make a last tutorial 09 wich covers picking behavior. Go from window coordinates to model coordinates is such a common task. I have played around with this, but only with software rendering (kha.graphics1). I have my model coordinates my view (only a vec3) and a projection plane wich i cover with rays. Then working with barycentric coordinates from the triangle (my great model;-) and if one ray target the triangle then calculate the depth. That works, but the real transforming pipeline with all the 4X4 matrices (especially the lookAt-matrix) overwhelms me a bit.

    No problem if you have no time for such a tutorial.
    And many thanks for negativ values in sliders.

    posted in Kode read more
  • W


    i try something like this:

        var g = framebuffer.g4;
        g.clear(Color.fromFloats(0.0, 0.0, 0.3), 1.0);  ...
        var g2 = framebuffer.g2;
        zui.begin(g2); ...

    But unfortunately that does not work. Zui is drawn but my model vanishes.

    Slider work with negativ values:-)

    posted in Kode read more
  • W

    i try the geometry shader for a wireframe example. The shaders compile without a error. I have used this example:
    wireframe with hidden edges
    (vertex shader -> vs.glsl, geometry shader -> gs.glsl, fragment shader -> fs.glsl)

        pipeline.vertexShader = Shaders.simple_vert;
        pipeline.geometryShader = Shaders.simple_geom;
        pipeline.fragmentShader = Shaders.simple_frag;

    But i get this error message:
    kha.graphics4.FragmentShader should be kha.graphics4.GeometryShader
    I have no idea why this error message occurs.

    Thanks for all the help that I have already found here:-)

    posted in Kode read more
  • W

    Great it works. Many thanks Robert , I have been wondering a typo that can not be.

    posted in Kode read more
  • W

    i have found this network / multiplayer example on git:

    I think there is a small typo in the readme:
    ... then navigate to "build/node" and start the server with node kha.js
    node kha.js => node server.js

    My problem is, i get this message when i calling >npm install:
    *ws@0.4.32 install /path to project/BlockArena/build/node/node_modules/w> (node-gyp rebuild 2> builderror.log) || (exit 0)

    make: Verzeichnis ,,/path to project/BlockArena/build/node/node_modules/ws/build" wird betreten
    CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
    bufferutil.target.mk:90: die Regel für Ziel ,,Release/obj.target/bufferutil/src/bufferutil.o" scheiterte
    make: Verzeichnis ,,/path to project/BlockArena/build/node/node_modules/ws/build" wird verlassen*

    I open two clients in my browser and have a strange behavior. The red blocks flicker in the left side of the canvas.
    An when i close one client (close tab in browser) i get this error from the server:
    throw er; // Unhandled 'error' event

    Error: channel closed
    at process.target.send (internal/child_process.js:523:16)
    at Object.kha_network_NodeProcessClient.send (/path to project/BlockArena/build/node/kha.js:14991:11)
    at Object.kha_network_Session.sendToEverybody (/path to project/BlockArena/build/node/kha.js:15365:11)
    at Object.kha_network_Session.update (/path to project/BlockArena/build/node/kha.js:15357:8)
    at Timeout.kha_SystemImpl.synch [as _onTimeout] (/path to project/BlockArena/build/node/kha.js:3277:29)
    at tryOnTimeout (timers.js:228:11)
    at Timer.listOnTimeout (timers.js:202:5)*

    I think that is because the server is not installed properly.
    My node version: 6.3.1
    npm version: 3.10.6
    and the kha version is from git.

    Before i found this demo, i have played a little bit with the node package 'ws'. Create sessions, store user-id und user-socket in a map send some bytes - nice and easy, but without the big features from the kha.network package (serialized objects, automatic synchronization, shared code between Client- and Server-App etc). Now I would never miss again these cool things.

    posted in Kode read more
  • W

    @webster said:

    remark to me;-)
    have a look at the painter* files in the debug-html5-resources folder, which should contain all the patterns that I need.

    now i think, i shoot a little bit to fast and to deep in the framework. The 'texture2D' is not defined in the painter-image.frag.essl file. Nevertheless, the files could be useful for me and my learning.

    posted in Kode read more

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