Attaching function keys to lava & ice script

Home Forums AR Sandbox Forum Attaching function keys to lava & ice script

Tagged: 

This topic contains 4 replies, has 4 voices, and was last updated by  dawsonll 1 month, 3 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #115718

    athompson
    Participant

    Can you guide me on how to assign the scripts to a function key that will allow for switching without exiting the program and restarting?

    #115720

    Oliver Kreylos
    Keymaster

    The first step is to create a shell script that will do the function you want, say copy a fragment program with lava over the standard fragment program:

    #!/bin/bash
    
    SHADERDIR=~/src/SARndbox-2.4/share/SARndbox-2.4/Shaders
    cp SHADERDIR/Lava.fs SHADERDIR/SurfaceAddWaterColor.fs

    You would call this “ToLava.sh” or something, store it in ~/src/SARndbox-2.4/bin, and make it executable:

    chmod a+x ~/src/SARndbox-2.4/bin/ToLava.sh

    Then you create a custom configuration file for SARndbox, as described in step 15 in the complete installation instructions. At the beginning of the “Tools” section, add “ScriptExecutorTool” to the tool class names, and bind a tool of that class to the key/button you want to use (L in this example):

    section Vrui
        section Desktop
            ...
            section Tools
                toolClassNames += (ScriptExecutorTool)
                ...
                section DefaultTools
                    ...
                    section LavaTool
                        toolClass ScriptExecutorTool
                        bindings ((Mouse, l))
                        executablePathName /home/<username>/src/SARndbox-2.4/bin/ToLava.sh
                    endsection
                    ...
                endsection
                ...
            endsection
            ...
        endsection
        ...
    endsection

    Replace <username> with your actual user name.

    You can create more of those tool binding section to bind other scripts to other keys/buttons, e.g., switching back to water.

    #116182

    nelsonb
    Participant

    I have been attempting to get this script to work, however I keep receiving an ‘Exit Code 1’ error when pressing a button while running the program. Any thoughts on what might be causing this?

    In the shell file, you have a the “Lava.sh” file type as the source file, however I see no such file created in the Shader Directory. Does one need to be created in order for the shell to function?

    • This reply was modified 7 months ago by  nelsonb.
    #116196

    Oliver Kreylos
    Keymaster

    You mean “Lava.fs,” with is a shader program that makes water look like lava. And yes, you need to create that. If you look into the SurfaceAddWaterColor.fs shader program, you’ll see some commented-out lines. Uncomment the “turbulence noise” line, and comment out the current float colorW=… line, and select the vec4 waterColor=… line that says “lava”, and the water will look like lava. If you save the original shader file as “Water.fs” and the changed one as “Lava.fs”, you can then switch between them using scripts like the above.

    #118350

    dawsonll
    Participant

    I’ve followed above, but not having any luck. Have tried different types of scripts for switching to lava from other forum contributors, but still no luck.

    Currently, just going as simple as I can, I have:

    ToLava.sh (saved in scripts and executed)

    #!/bin/bash

    SHADERDIR=~/src/SARndbox-2.6/share/SARndbox-2.6/Shaders
    cp SHADERDIR/Lava.fs SHADERDIR/SurfaceAddWaterColor.fs

    Have Lava.fs file in Shaders modified as recommended above.

    Modified SARndbox.cfg with section LavaTool (here’s my config file: https://docs.google.com/document/d/1jkgfkc5hpP_YrcuLKyp9_W2L-jiGdegBfIJrTK3C5gk/edit?usp=sharing)

    Not sure what to do next…still just get the same blue water. One thing I see seems strange. I opened SurfaceAddWaterColor.fs in a terminal window using the command:
    xed ~/src/SARndbox-2.6/shar/SARndbox-2.6/Shaders/SurfaceAddWaterColor.fs

    and it was blank. The file looks normal when opened otherwise.

    Thanks for your help! I’m a novice.

    • This reply was modified 1 month, 3 weeks ago by  dawsonll.
    • This reply was modified 1 month, 3 weeks ago by  dawsonll.
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

Comments are closed.