![]() |
|
|||||||
| Development Help Help for building applications or diagnosing problems with WWJ |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Worldwind Developer
Join Date: Jan 2006
Location: Hobart, Australia
Posts: 754
![]() |
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
__________________
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 |
|
Junior Member
Join Date: Sep 2010
Posts: 10
![]() |
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 |
|
Junior Member
Join Date: Sep 2010
Posts: 10
![]() |
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 |
|
Junior Member
Join Date: Sep 2010
Posts: 10
![]() |
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 |
|
Member
Join Date: Apr 2010
Posts: 31
![]() |
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");
Code:
if(layer instanceof WMSTiledImageLayer)
{
WMSTiledImageLayer tile = (WMSTiledImageLayer)layer;
((WMSShadedImageLayer)tile).setBrightness(brightness);
}
Code:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: gov.nasa.worldwind.wms.WMSTiledImageLayer cannot be cast to dsto.layers.WMSShadedImageLayer Code:
((WMSShadedImageLayer)tile).setBrightness(brightness); 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)
Code:
WMSShadedImageLayer newlayer = new WMSShadedImageLayer((WMSTiledImageLayer)l); Thanks for any help |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Sep 2010
Posts: 10
![]() |
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 |
|
Worldwind Developer
Join Date: Jan 2006
Location: Hobart, Australia
Posts: 754
![]() |
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 |
|
Junior Member
Join Date: Mar 2010
Posts: 23
![]() |
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 |
|
|
|
![]() |
| Tags |
| glsl, shaders |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
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 |