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 09-26-2009, 10:03 AM   #1
what_nick
Worldwind Developer
 
Join Date: Jan 2006
Location: Hobart, Australia
Posts: 754
what_nick is an unknown quantity at this point
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
File Type: jpg shader_ww.jpg (57.0 KB, 349 views)
Attached Files
File Type: zip whatnickworld.zip (211.9 KB, 159 views)
__________________
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-14-2010, 09:38 PM   #2
ismakun
Junior Member
 
Join Date: Sep 2010
Posts: 10
ismakun is on a distinguished road
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.
ismakun is offline   Reply With Quote
Old 09-14-2010, 11:10 PM   #3
ismakun
Junior Member
 
Join Date: Sep 2010
Posts: 10
ismakun is on a distinguished road
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?
ismakun is offline   Reply With Quote
Old 09-16-2010, 03:31 PM   #4
ismakun
Junior Member
 
Join Date: Sep 2010
Posts: 10
ismakun is on a distinguished road
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.
ismakun is offline   Reply With Quote
Old 09-21-2010, 05:04 AM   #5
duindain
Member
 
Join Date: Apr 2010
Posts: 31
duindain is on a distinguished road
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
duindain is offline   Reply With Quote
Old 09-27-2010, 03:43 PM   #6
ismakun
Junior Member
 
Join Date: Sep 2010
Posts: 10
ismakun is on a distinguished road
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.
ismakun is offline   Reply With Quote
Old 09-28-2010, 06: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

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:


what_nick is offline   Reply With Quote
Old 09-28-2010, 10:35 AM   #8
C0ldf1re
Junior Member
 
C0ldf1re's Avatar
 
Join Date: Mar 2010
Posts: 23
C0ldf1re is on a distinguished road
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
C0ldf1re is offline   Reply With Quote
Reply

Tags
glsl, shaders


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


All times are GMT +1. The time now is 01:05 PM.


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