Jump to content

SpiderPig

Developers
  • Posts

    2,205
  • Joined

  • Last visited

Posts posted by SpiderPig

  1. Thanks, I did this in BeginDispatch():

    switch (hook)
    {
    case ComputeHook::RENDER:
    	world->AddHook(HookID::HOOKID_RENDER, BeginComputeShaderDispatch, info, !oneTime);
    	break;
    case ComputeHook::TRANSFER:
    	world->AddHook(HookID::HOOKID_RENDER, BeginComputeShaderDispatch, info, !oneTime);
    	break;
    }

    It doesn't crash now and the cubes spin but remain pink.

    ComputeShaderCubes.thumb.png.0fe4c85bc8fba5a7739d5bf9b08cfbfe.png

  2. Hey @klepto2 I just tried you compute shader example here.  I'm using the latest shaders and I'm getting a consistent access violation in this function:

    void Reset(VkCommandBuffer buffer)
    {
    	vkCmdResetQueryPool(buffer, _queryPool, 0, 2);
    }

    Any insight you might have is appreciated. :)

  3. Would it be possible to see an added component affect the object it was added too in the editor?  Like the Mover component, I add it and then change the rotation parameter and start seeing the object rotate.  I can see how it could work for Lua components but maybe not C++ components.  Anyway just a thought.  :)

  4. While there is no viewer in the shader editor (probably will be once Ultra supports C#) you can create a file watcher in your application to watch the changes you make in real-time.  Within a second or two ;)

    Add this at the start of your program.

    auto watcher = CreateFileSystemWatcher("Materials");

    And add this to your loop.

    while (PeekEvent()) {
        auto ev = WaitEvent();
    
        if (ev.id == EVENT_FILECHANGE or ev.id == EVENT_FILECREATE)
        {
            //Look for a loaded asset with this file path
            auto asset = FindCachedAsset(ev.text);
            if (asset)
            {
                //Reload the modified asset
                if (asset->As<Material>() != nullptr) {
                    auto material = asset->As<Material>();
                    vector<shared_ptr<Texture>> textures;
                    for (int id = 0; id < 16; id++) {
                        auto tex = material->GetTexture(id);
                         textures.push_back(tex);
                    }
                    asset->Reload();
    
                    //If you assign textures progmatically you need to do this to make sure the newly loaded material has them too.
                    material = asset->As<Material>();
                    for (int id = 0; id < 16; id++) {
                    material->SetTexture(textures[id], id);
                    }
                }
                else {
                    asset->Reload();
                }
            }
        }
    }

    You can also setup the shader project to automatically compile and export to multiple projects that may use it.

    In 'Preferences' under 'Export Options' you can browse to any one of your Ultra projects and add them to the list.  This list will be saved between any shader project.  You then need to check which Ultra project you want the shader to be exported to and then check 'Auto Export' and 'Save'.

    Every time the shader project is changed it will attempt to compile.  If the compile is successful and 'Auto Export' is checked it will copy all relevant files over to each of the selected Ultra projects in the 'Materials' folder.

    If 'Auto Export" is disabled, you can go to File->Export All.

    This is mine.

    ExportOptions.thumb.png.3b44c883fbb960894b6489515656dddb.png

    If you have the code above running in your application and your app is running as you edit your shader, you should see it update as you make changes. :)

    • Like 2
  5. Took a few days but I now have high res normal maps generated on the fly as patch's of real-world heightmap data are streamed in.  Need to get multithreading working now as its a bit slow.  Materials are painted based on slope in the shader.  Still loads of work to do there too.

    StreamingVoxelTerrainNormalMaps.thumb.png.da5281cb639d23aae83aa4d710205d9e.png

    • Like 1
  6. I have packed integers and floats into a texture to use in my shader.  Information is packed into the texture by poking a buffer and then assigning that buffer to an RGBA texture.  The following code extracts an integer from a texelFetch result in the fragment shader.  It seems to work well.

    int BytesToInteger( in vec4 pixel ) {
    	return ( int( ( pixel.w * 255.0f ) ) << 24 ) | ( int( ( pixel.z * 255.0f ) ) << 16 ) | ( int( ( pixel.y * 255.0f ) ) << 8 ) | int( ( pixel.x * 255.0f ) );
    }

    However the same process does not work for floats and I'm sure there is a reason why but I can't figure it out.  Any one know the answer? <_<

    float BytesToFloat( in vec4 pixel ) {
    	return float( ( int( ( pixel.w * 255.0f ) ) << 24 ) | ( int( ( pixel.z * 255.0f ) ) << 16 ) | ( int( ( pixel.y * 255.0f ) ) << 8 ) | int( ( pixel.x * 255.0f ) ) );
    }

     

×
×
  • Create New...