World Wind Forums

Go Back   World Wind Forums > WorldWind JAVA forums > Development Help

Development Help Help for building applications or diagnosing problems with WWJ

Reply
 
Thread Tools Display Modes
Old 12-23-2008, 10:44 PM   #1
tve
Member
 
Join Date: Jun 2007
Posts: 98
tve is on a distinguished road
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
File Type: zip shader_support_051308.zip (6.2 KB, 323 views)
__________________
~
Some images of WWJ stuff I have been working on...
http://picasaweb.google.com/tve9999/...35840816720994
tve is offline   Reply With Quote
Old 12-24-2008, 11:08 AM   #2
patmurris
WWJ Consultant
 
patmurris's Avatar
 
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
patmurris is an unknown quantity at this point
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
patmurris is offline   Reply With Quote
Old 12-24-2008, 06:11 PM   #3
baellwe
weekend warrior
 
Join Date: May 2008
Posts: 95
baellwe is on a distinguished road
Thumbs up

good work, your screens are awesome.
baellwe is offline   Reply With Quote
Old 01-18-2009, 11:04 PM   #4
Omega
Member
 
Join Date: Oct 2008
Posts: 45
Omega is on a distinguished road
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.
Omega is offline   Reply With Quote
Old 01-22-2009, 03:13 PM   #5
Gor
Junior Member
 
Join Date: Apr 2008
Posts: 12
Gor is on a distinguished road
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
Gor is offline   Reply With Quote
Old 01-28-2009, 06:16 AM   #6
tve
Member
 
Join Date: Jun 2007
Posts: 98
tve is on a distinguished road
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
tve is offline   Reply With Quote
Old 09-09-2009, 04:35 AM   #7
what_nick
Worldwind Developer
 
Join Date: Jan 2006
Location: Hobart, Australia
Posts: 754
what_nick is an unknown quantity at this point
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:


what_nick is offline   Reply With Quote
Old 09-09-2009, 08:53 AM   #8
what_nick
Worldwind Developer
 
Join Date: Jan 2006
Location: Hobart, Australia
Posts: 754
what_nick is an unknown quantity at this point
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.
__________________
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:



Last edited by m_k; 01-02-2010 at 10:14 PM.
what_nick is offline   Reply With Quote
Reply

Tags
glsl shader code


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Visualising the World Wind Cache and missing tiles canosso Add-ons & Scripts 0 01-20-2005 03:39 PM


All times are GMT +1. The time now is 10:18 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.