Results 1 to 8 of 8

Thread: GLSL Shader support that renders tiles correctly

  1. #1

    Default GLSL Shader support that renders tiles correctly

    Hi All,

    I haven't been working with WWJ for a while now, but I have had several requests for help with getting the tile renderer working correctly with GLSL shaders as in the application screenshots I have submitted. I submitted the code for inclusion with WWJ some time ago, but never received a response. I will just post some sample code here in case it might help someone out. Have fun.
    tve

    http://picasaweb.google.com/tve9999/...indJavaImages#
    Attached Files Attached Files
    ~
    Some images of WWJ stuff I have been working on...
    http://picasaweb.google.com/tve9999/...35840816720994

  2. #2
    WWJ Consultant patmurris's Avatar
    Join Date
    Jun 2005
    Location
    Saint-Paul de Vence, Alpes Maritimes, France
    Posts
    3,383

    Default

    Thanks for the little Christmas present
    I have been experimenting a bit with shaders too, but it is not a priority to integrate them in the SDK yet. It will come at some point so be assured i'm keeping your contributions in a safe place for that.
    My World Wind Java Blog & WW.net Plugins page

  3. #3
    weekend warrior
    Join Date
    May 2008
    Posts
    95

    Thumbs up

    good work, your screens are awesome.

  4. #4

    Default

    Thanks very much tve!

    I've been trying to get shaders working for a while, but the tiling was messed up. The solution was found in your fragment shader: I wasn't discarding when the alpha texture was less than 1.

    It is possible to use shaders without modifications to the SurfaceTileRenderer class. Simply create a layer that you wish to be shaded, and override the render(DrawContext dc) function like so:
    Code:
    	public void render(DrawContext dc)
    	{
    		GL gl = dc.getGL();
    		gl.glUseProgram(shaderprogram);
    		super.render(dc);
    		gl.glUseProgram(0);
    	}
    Note: you must initialize the shaderprogram sometime in the GL thread.

  5. #5
    Junior Member
    Join Date
    Apr 2008
    Posts
    12

    Default

    hi tve, i have no experience with shaders. Can you provide and example or more information about how to produce this output:
    http://picasaweb.google.com/tve9999/...36747054820562

    thx
    gor

  6. #6

    Default

    Omega,
    No problem. I'm glad you found the example useful. Hopefully we will see shaders integrated into the core one of these days.

    Gor,
    I will try to put something together for implementing that demo. I submitted code at one time to implement that very screen shot. It was not integrated at that time because shaders are a low priority for the WWJ team. The WWJ base code has changed significantly since then and it will probably take me some time to figure out how to get it working again.

    -tve
    http://geoagsys.com/
    http://tve-consulting.com/


    Quote Originally Posted by Omega View Post
    Thanks very much tve!
    ~
    Some images of WWJ stuff I have been working on...
    http://picasaweb.google.com/tve9999/...35840816720994

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

    Default

    I am working on shaders for WMS based layers ... based on the simple override of render method and fragment shaders. I am going to reuse the GLSL class supplied to manage the set of shaders. I will come back with results as soon as I have something sensible.

    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
    Worldwind Developer
    Join Date
    Jan 2006
    Location
    Hobart, Australia
    Posts
    741

    Default

    That was ridiculously simple once I figured out how to pass the textures to the shader. This is what i have in my class extended from WMSTiledImageLayer:
    Code:
    //Override render allow application of shaders
        
        @Override
        public void render(DrawContext dc) {
            // TODO Auto-generated method stub
            glsl.useShaders();
            glsl.startShader();
            GL gl = dc.getGL();
            gl.glUniform1i(glsl.getUniformLocation("tile_image"),0);    //use texture unit 0
            gl.glUniform1i(glsl.getUniformLocation("alpha_mask"),1);    //use texture unit 1
            super.render(dc);
            glsl.endShader();
        }
    
        //Load shaders in the pre-render pass
        @Override
        protected void doPreRender(DrawContext dc) {
            // TODO Auto-generated method stub
            if(glsl==null)
            {
                glsl = new ContrastGLSL(dc.getGL());
                //System.out.println(glsl.isShaderSupported());
                glsl.loadVertexShader(ContrastGLSL.vertfile);
                glsl.loadFragmentShader(ContrastGLSL.fragfile);
            }
            super.doPreRender(dc);    
        }
    And it works like a charm .. will fail on machines with no shader support but it is just a test.

    Cheers,

    what_nick.
    Last edited by m_k; 01-02-2010 at 10:14 PM.
    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:



Thread Information

Users Browsing this Thread

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

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
  •