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 08-16-2010, 02:36 PM   #1
jwheeler
Junior Member
 
Join Date: Apr 2009
Location: UK
Posts: 16
jwheeler is on a distinguished road
Default GLSL fragment shader problem

Hi
I am using a fragment shader (below) to create a greyscale earth, but it's causing a problem with some tiles (see screenshot).

Looks like the its sometimes using the texture coordinates from the neighbouring tile for some reason. Anyone had this problem or know how to solve it?

Note the tiles are rendered correctly if I disable the shader.

Thanks

Code:
uniform sampler2D testTexture;

void main( void )
{
	vec4 texelColor = texture2D( testTexture, gl_TexCoord[0].xy );
	vec4 greyWeights = vec4(0.3, 0.59, 0.11, 1.0);
	vec4 scaledColor = texelColor * greyWeights;
	float luminance = scaledColor.r + scaledColor.g + scaledColor.b;
	gl_FragColor = vec4( luminance, luminance, luminance, texelColor.a );
}
Attached Images
File Type: jpg World Wind greyscale prob.JPG (54.7 KB, 254 views)

Last edited by jwheeler; 08-16-2010 at 02:37 PM. Reason: Clarification
jwheeler is offline   Reply With Quote
Old 08-18-2010, 06:01 PM   #2
baellwe
weekend warrior
 
Join Date: May 2008
Posts: 95
baellwe is on a distinguished road
Default

I'm not saying that this is your problem, but I have seen similar behavior on 'vanilla world' wind setups where the terrain data has become corrupted or when graphics driver updates are needed. You might trying deleting all of your elevation data and/or updating graphics drivers. It might just help
baellwe is offline   Reply With Quote
Old 08-22-2010, 09:48 PM   #3
remleduff
Senior Member
 
Join Date: Jun 2007
Posts: 218
remleduff is on a distinguished road
Default

"Normal" World Wind rendering uses an alpha mask texture (through multi-texture rendering) so that it only renders the portion of the surface tile which is covered by the texture. That's how it combines several different textures of various sizes together to cover a tile.

Once you use a shader, you no longer necessarily benefit from the alpha masking which all takes place in the fixed-function pipeline. So in your fragment shader, you need to discard any pixes for texture coords less than 0 or greater than 1.

Something like:

if (gl_TexCoord[0].s < 0 || gl_TexCoord[0].s > 1) discard;
if (gl_TexCoord[0].t < 0 || gl_TexCoord[0].t > 1) discard;
remleduff is offline   Reply With Quote
Old 05-18-2011, 05:06 PM   #4
jjones
Junior Member
 
Join Date: Jan 2008
Location: Huntsville, AL
Posts: 24
jjones is on a distinguished road
Default

I just came across this posting and it fixed an issue have been having since upgrading WWJ this week.. I had been using the version of world wind java from about May 2010, and it worked fine with my shader. I upgraded this week to the newest world wind java and started getting the same incorrectly rendered tile. Adding those 2 lines to my shader fixed the issue. Thanks.
jjones is offline   Reply With Quote
Reply


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
Normal mapping (GLSL shader) Omega Feature Discussion 12 09-11-2011 10:53 PM
Updating GLSL support with new JOGL what_nick Development Help 7 09-28-2010 10:35 AM
Custom terrain tile visibility/altitude problem Peter Skvarenina Development Help 6 02-26-2010 10:55 PM
GLSL Shader support that renders tiles correctly tve Development Help 7 09-09-2009 08:53 AM
Problem with terrain and its modification bako Development Help 1 02-23-2009 05:35 PM


All times are GMT +1. The time now is 05:51 AM.


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