Results 1 to 8 of 8

Thread: Updating GLSL support with new JOGL

  1. #1
    Worldwind Developer
    Join Date
    Jan 2006
    Location
    Hobart, Australia
    Posts
    754

    Default Updating GLSL support with new JOGL

    Hi all,

    I would like to do some in WW texture operations and shader support would be nice. So as I implemented some processing of WMS tiles, I sample code build against the latest nightly SVN is attached.

    I hiccup I am having is in passing a uniform to the shader to control layer brightness. I have tested the shader in Rendermonkey and it works fine.

    I have tried debugging for a while to no avail so another check will be really appreciated. I also noticed that the latest incarnation of Jogl adds shader support utility classes, is it possible to update the Jogl used by worldwind ?

    Cheers,

    what_nick
    Attached Images Attached Images
    Attached Files Attached Files
    Coding This and That in World Wind and helping new people out, as long as they don't pester too much.
    Currently blogging at: http://whatnicklife.blogspot.com
    Working at:
    Aerometrex - http://aerometrex.com.au/blog/
    Impact so far:



  2. #2
    Junior Member
    Join Date
    Sep 2010
    Posts
    10

    Default

    Sorry for reviving an old thread but you were able to work this out? I need to implement this feature but so far the shader is not affecting at all the layer.

  3. #3
    Junior Member
    Join Date
    Sep 2010
    Posts
    10

    Default

    I got it to work right now but I have to hardcode the value inside the shader for brightness.

    uniform sampler2D tile_image;
    uniform sampler2D alpha_mask;
    uniform float brightness;

    void main (void)

    {
    vec4 tile_val = texture2D(tile_image, gl_TexCoord[0].st);
    vec4 alpha_val = texture2D(alpha_mask, gl_TexCoord[1].st);

    brightness = -.38;

    gl_FragColor = vec4 (tile_val.rgba + brightness );
    }

    For some reason adjusting the value of brightness through WWJ using

    gl.glUniform1f(glsl.getUniformLocation(" brightness"), brightness); //use brightness

    is not working.

    Any ideas as to what is happening here?

  4. #4
    Junior Member
    Join Date
    Sep 2010
    Posts
    10

    Default

    Nevermind got it to work.

    Before passing the values to the uniforms you first need to start the shader.

    gl.glUseProgram(programObject);

    then you can safely pass the values:

    gl.glUniform1i(uniform1,0);

    Now I got the brightness feature working.

  5. #5

    Default Not sure why i cant cast to extended class

    Could anyone shed some light on this please, sorry if its obvious answer
    When i try to use What_nicks code on "Blue Marble (WMS) 2004" or "Bathymetry Low Resolution" or any of the contours that are WMSTiledImageLayer's
    i get a runtime error
    I am getting the layer with
    Code:
    getLayerByName("Blue Marble (WMS) 2004");
    and so on for each layer type, inside the updateBrightness function i check it is the right kind of tile
    Code:
    if(layer instanceof WMSTiledImageLayer)
    {
        WMSTiledImageLayer tile = (WMSTiledImageLayer)layer;
        ((WMSShadedImageLayer)tile).setBrightness(brightness);
    }
    The runtime error is
    Code:
    Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: gov.nasa.worldwind.wms.WMSTiledImageLayer cannot be cast to dsto.layers.WMSShadedImageLayer
    on the
    Code:
    ((WMSShadedImageLayer)tile).setBrightness(brightness);
    line
    My WMSShadedImageLayer class is copied from Nicks one no changes
    Ive tried checking all layers and reloading them if they are one of the specific ones i want to brighten as a WMSShadedImageLayer but i get a error in levelset when i try passing in the values from the original tiledImageLayer with that method
    Code:
    Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Invalid level descriptor fields: tile delta sector number of levels 
            at gov.nasa.worldwind.util.LevelSet.<init>(LevelSet.java:106)
    I was attempting to just pass in the layer as an argument to the WMSShadedImageLayer constructor im not sure how to extract the layers values and use them to create a new layer since the get and set Values and various other functions seem to accept different types of values from what the return
    Code:
    WMSShadedImageLayer newlayer = new WMSShadedImageLayer((WMSTiledImageLayer)l);
    I would love to have shaders working correctly mostly to tweak color values for projector viewing as the sea is to dark at present

    Thanks for any help

  6. #6
    Junior Member
    Join Date
    Sep 2010
    Posts
    10

    Default

    You cannot cast a WMSTiledImageLayer to a WMSShadedImageLayer just like that because all methods inside the WMSShadedImageLayer are not defined in the WMSTiledImageLayer. You need to first create the layer as a WMSShadedImageLayer and then you can cast it when you retrieve it. One way to do this is to retrieve the layer data from the server and create your the layer and add it to the model.

    Hope that helps.

  7. #7
    Worldwind Developer
    Join Date
    Jan 2006
    Location
    Hobart, Australia
    Posts
    754

    Default

    Hi Guys,

    I have been away from forums for a while working on my PhD. Glad to see somebody using the shader code. A lot of everyday image enhancement can be done in shaders making imagery viewing and manipulation faster.

    Could you post the brightness shader etc. We can start compiling all the worldwind shader based code in one place and building up a custom self-describing layer which can be attached to a pixel shader file, the glsl studios from ATI and NVIDIA have description tags of tunable parameters.

    Something to think about.

    Cheers,

    what_nick.
    Coding This and That in World Wind and helping new people out, as long as they don't pester too much.
    Currently blogging at: http://whatnicklife.blogspot.com
    Working at:
    Aerometrex - http://aerometrex.com.au/blog/
    Impact so far:



  8. #8
    Junior Member C0ldf1re's Avatar
    Join Date
    Mar 2010
    Posts
    21

    Default

    Quote Originally Posted by ismakun View Post
    ... You need to first create the layer as a WMSShadedImageLayer and then you can cast it when you retrieve it...
    That has solved another of my problems! Casting was the answer. Thanks.
    Live fast. Die young. Leave a beautiful body of code. Testing: invoicing freeware Testing: accounts software free downloads UK

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. GLSL Shader support that renders tiles correctly
    By tve in forum Development Help
    Replies: 7
    Last Post: 09-09-2009, 08:53 AM
  2. What version of JOGL is this with WWJ 1.6??
    By naql in forum Development Help
    Replies: 2
    Last Post: 06-22-2009, 04:22 PM
  3. intel_region /mesa internal errror while loading app
    By nmangal in forum Development Help
    Replies: 0
    Last Post: 11-12-2008, 06:34 PM
  4. WWJ SDK to abstract JOGL to make a map server
    By mikequentel in forum Applications
    Replies: 0
    Last Post: 05-01-2008, 07:32 PM
  5. JOGL forum/Behavior of WWJ Applet in Browser
    By rogene in forum Development Help
    Replies: 1
    Last Post: 04-21-2008, 02:39 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •