Crash jMonkey Application

Hey,



The jmonkey application crashes when I start it.



System specs:

Windows 7 64 bit

ATI Mobility Radeon HD 5470 fully updated



I hope anyone knows a fix for my problem.



Thank you for any effort.



My error:



cross(T[2], T[0]),

cross(T[0], T[1])) / det;

}





mat3 computeTangentFrame(in vec3 N, in vec3 P, in vec2 UV) {

vec3 dp1 = dFdx§;

vec3 dp2 = dFdy§;

vec2 duv1 = dFdx(UV);

vec2 duv2 = dFdy(UV);



// solve the linear system

vec3 dp1xdp2 = cross(dp1, dp2);

mat2x3 inverseM = mat2x3(cross(dp2, dp1xdp2), cross(dp1xdp2, dp1));



vec3 T = inverseM * vec2(duv1.x, duv2.x);

vec3 B = inverseM * vec2(duv1.y, duv2.y);



// construct tangent frame

float maxLength = max(length(T), length(B));

T = T / maxLength;

B = B / maxLength;



return mat3(T, B, N);

}



float saturate(in float val){

return clamp(val,0.0,1.0);

}



vec3 saturate(in vec3 val){

return clamp(val,vec3(0.0),vec3(1.0));

}



vec3 getPosition(in float depth, in vec2 uv){

vec4 pos = vec4(uv, depth, 1.0) * 2.0 - 1.0;

pos = m_ViewProjectionMatrixInverse * pos;

return pos.xyz / pos.w;

}



// Function calculating fresnel term.

// - normal - normalized normal vector

// - eyeVec - normalized eye vector

float fresnelTerm(in vec3 normal,in vec3 eyeVec){

float angle = 1.0 - max(0.0, dot(normal, eyeVec));

float fresnel = angle * angle;

fresnel = fresnel * fresnel;

fresnel = fresnel * angle;

return saturate(fresnel * (1.0 - saturate(m_R0)) + m_R0 - m_RefractionStreng

th);

}



// NOTE: This will be called even for single-sampling

vec4 main_multiSample(int sampleNum){



float sceneDepth = fetchTextureSample(m_DepthTexture, texCoord, sampleNum).r

;

vec3 color2 = fetchTextureSample(m_Texture, texCoord, sampleNum).rgb;



vec3 color = color2;

vec3 position = getPosition(sceneDepth, texCoord);



float level = m_WaterHeight;



// If we are underwater let’s leave out complex computations

if(level >= m_CameraPosition.y){

return vec4(color2, 1.0);

}



float isAtFarPlane = step(0.99998, sceneDepth);

//#ifndef ENABLE_RIPPLES

// This optimization won’t work on NVIDIA cards if ripples are enabled

if(position.y > level + m_MaxAmplitude + isAtFarPlane * 100.0){

return vec4(color2, 1.0);

}

//#endif



vec3 eyeVec = position - m_CameraPosition;

float diff = level - position.y;

float cameraDepth = m_CameraPosition.y - position.y;



// Find intersection with water surface

vec3 eyeVecNorm = normalize(eyeVec);

float t = (level - m_CameraPosition.y) / eyeVecNorm.y;

vec3 surfacePoint = m_CameraPosition + eyeVecNorm * t;



vec2 texC = vec2(0.0);

int samples = 1;

if (m_UseHQShoreline){

samples = 10;

}



float biasFactor = 1.0 / samples;

for (int i = 0; i < samples; i++){

texC = (surfacePoint.xz + eyeVecNorm.xz * biasFactor) * scale + m_Time

0.03 * m_WindDirection;



float bias = texture(m_HeightMap, texC).r;



bias = biasFactor;

level += bias * m_MaxAmplitude;

t = (level - m_CameraPosition.y) / eyeVecNorm.y;

surfacePoint = m_CameraPosition + eyeVecNorm * t;

}



float depth = length(position - surfacePoint);

float depth2 = surfacePoint.y - position.y;



// XXX: HACK ALERT: Increase water depth to infinity if at far plane

// Prevents “foam on horizon” issue

// For best results, replace the “100.0” below with the

// highest value in the m_ColorExtinction vec3

depth += isAtFarPlane * 100.0;

depth2 += isAtFarPlane * 100.0;



eyeVecNorm = normalize(m_CameraPosition - surfacePoint);



// Find normal of water surface

float normal1 = textureOffset(m_HeightMap, texC, ivec2(-1, 0)).r;

float normal2 = textureOffset(m_HeightMap, texC, ivec2( 1, 0)).r;

float normal3 = textureOffset(m_HeightMap, texC, ivec2( 0, -1)).r;

float normal4 = textureOffset(m_HeightMap, texC, ivec2( 0, 1)).r;



vec3 myNormal = normalize(vec3((normal1 - normal2) * m_MaxAmplitude,m_Normal

Scale,(normal3 - normal4) * m_MaxAmplitude));

vec3 normal = vec3(0.0);



if (m_UseRipples){

texC = surfacePoint.xz * 0.8 + m_WindDirection * m_Time
1.6;

mat3 tangentFrame = computeTangentFrame(myNormal, eyeVecNorm, texC);

vec3 normal0a = normalize(tangentFrame
(2.0 * texture(m_NormalMap, texC)

.xyz - 1.0));



texC = surfacePoint.xz * 0.4 + m_WindDirection * m_Time* 0.8;

tangentFrame = computeTangentFrame(myNormal, eyeVecNorm, texC);

vec3 normal1a = normalize(tangentFrame*(2.0 * texture(m_NormalMap, texC)

.xyz - 1.0));



texC = surfacePoint.xz * 0.2 + m_WindDirection * m_Time * 0.4;

tangentFrame = computeTangentFrame(myNormal, eyeVecNorm, texC);

vec3 normal2a = normalize(tangentFrame*(2.0 * texture(m_NormalMap, texC)

.xyz - 1.0));



texC = surfacePoint.xz * 0.1 + m_WindDirection * m_Time * 0.2;

tangentFrame = computeTangentFrame(myNormal, eyeVecNorm, texC);

vec3 normal3a = normalize(tangentFrame*(2.0 * texture(m_NormalMap, texC)

.xyz - 1.0));



normal = normalize(normal0a * normalModifier.x + normal1a * normalModifi

er.y +normal2a * normalModifier.z + normal3a * normalModifier.w);

// XXX: Here’s another way to fix the terrain edge issue,

// But it requires GLSL 1.3 and still looks kinda incorrect

// around edges

normal = isnan(normal.x) ? myNormal : normal;

//if (position.y > level){

// gl_FragColor = vec4(color2 + normal0.0001, 1.0);

// return;

//}

}else{

normal = myNormal;

}



vec3 refraction = color2;

if (m_UseRefraction){

// texC = texCoord.xy+ m_ReflectionDisplace * normal.x;

texC = texCoord.xy;

texC += sin(m_Time
1.8 + 3.0 * abs(position.y)) * (refractionScale * mi

n(depth2, 1.0));

#ifdef RESOLVE_MS

ivec2 iTexC = ivec2(texC * textureSize(m_Texture));

refraction = texelFetch(m_Texture, iTexC, sampleNum).rgb;

#else

ivec2 iTexC = ivec2(texC * textureSize(m_Texture, 0));

refraction = texelFetch(m_Texture, iTexC, 0).rgb;

#endif

}



vec3 waterPosition = surfacePoint.xyz;

waterPosition.y -= (level - m_WaterHeight);

vec4 texCoordProj = m_TextureProjMatrix * vec4(waterPosition, 1.0);



texCoordProj.x = texCoordProj.x + m_ReflectionDisplace * normal.x;

texCoordProj.z = texCoordProj.z + m_ReflectionDisplace * normal.z;

texCoordProj /= texCoordProj.w;

texCoordProj.y = 1.0 - texCoordProj.y;



vec3 reflection = texture(m_ReflectionMap, texCoordProj.xy).rgb;



float fresnel = fresnelTerm(normal, eyeVecNorm);



float depthN = depth * m_WaterTransparency;

float waterCol = saturate(length(m_LightColor.rgb) / m_SunScale);

refraction = mix(mix(refraction, m_WaterColor.rgb * waterCol, saturate(depth

N / visibility)),

m_DeepWaterColor.rgb * waterCol, saturate(depth2 / m_ColorExtinction));



vec3 foam = vec3(0.0);

if (m_UseFoam){

texC = (surfacePoint.xz + eyeVecNorm.xz * 0.1) * 0.05 + m_Time * 0.05 *

m_WindDirection + sin(m_Time * 0.001 + position.x) * 0.005;

vec2 texCoord2 = (surfacePoint.xz + eyeVecNorm.xz * 0.1) * 0.05 + m_Time

  • 0.1 * m_WindDirection + sin(m_Time * 0.001 + position.z) * 0.005;



    if(depth2 < m_FoamExistence.x){

    foam = (texture2D(m_FoamMap, texC).r + texture2D(m_FoamMap, texCoord

    2)).rgb * vec3(m_FoamIntensity);

    }else if(depth2 < m_FoamExistence.y){

    foam = mix((texture2D(m_FoamMap, texC) + texture2D(m_FoamMap, texCoo

    rd2)) * m_FoamIntensity , vec4(0.0),

    (depth2 - m_FoamExistence.x) / (m_FoamExistence.y - m_FoamExiste

    nce.x)).rgb;

    }





    if(m_MaxAmplitude - m_FoamExistence.z> 0.0001){

    foam += ((texture2D(m_FoamMap, texC) + texture2D(m_FoamMap, texCoord

    2)) * m_FoamIntensity * m_FoamIntensity * 0.3 *

    saturate((level - (m_WaterHeight + m_FoamExistence.z)) / (m_MaxAm

    plitude - m_FoamExistence.z))).rgb;

    }

    foam = m_LightColor.rgb;

    }



    vec3 specular = vec3(0.0);

    if (m_UseSpecular){

    vec3 lightDir=normalize(m_LightDir);

    vec3 mirrorEye = (2.0 * dot(eyeVecNorm, normal) * normal - eyeVecNorm);

    float dotSpec = saturate(dot(mirrorEye.xyz, -lightDir) * 0.5 + 0.5);

    specular = vec3((1.0 - fresnel) * saturate(-lightDir.y) * ((pow(dotSpec,

    512.0)) * (m_Shininess * 1.8 + 0.2)));

    specular += specular * 25.0 * saturate(m_Shininess - 0.05);

    //foam does not shine

    specular=specular * m_LightColor.rgb - (5.0 * foam);

    }



    color = mix(refraction, reflection, fresnel);

    color = mix(refraction, color, saturate(depth * m_ShoreHardness));

    color = saturate(color + max(specular, foam ));

    color = mix(refraction, color, saturate(depth
    m_FoamHardness));





    // XXX: HACK ALERT:

    // We trick the GeForces to think they have

    // to calculate the derivatives for all these pixels by using step()!

    // That way we won’t get pixels around the edges of the terrain,

    // Where the derivatives are undefined

    return vec4(mix(color, color2, step(level, position.y)), 1.0);

    }



    void main(){

    #ifdef RESOLVE_MS

    vec4 color = vec4(0.0);

    for (int i = 0; i < m_NumSamples; i++){

    color += main_multiSample(i);

    }

    gl_FragColor = color / m_NumSamples;

    #else

    outFragColor = main_multiSample(0);

    #endif

    }





    Jun 24, 2011 2:13:52 PM com.jme3.app.Application handleError

    SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

    com.jme3.renderer.RendererException: compile error in:ShaderSource[name=Common/M

    atDefs/Water/Water15.frag, defines, type=Fragment] error:Fragment shader failed

    to compile with the following errors:

    WARNING: 0:18: warning(#239) Declaration should include a precision qualifier or

    the default precision should have been previously declared

    ERROR: 0:19: error(#155) Internal error wrong operand type built in unary operat

    or function. Type: in sampler2DMS

    ERROR: error(#273) 1 compilation errors. No code generated



    at com.jme3.renderer.lwjgl.LwjglRenderer.updateShaderSourceData(LwjglRen

    derer.java:989)

    at com.jme3.renderer.lwjgl.LwjglRenderer.updateShaderData(LwjglRenderer.

    java:1024)

    at com.jme3.renderer.lwjgl.LwjglRenderer.setShader(LwjglRenderer.java:11

    05)

    at com.jme3.material.Material.render(Material.java:890)

    at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:427

    )

    at com.jme3.post.FilterPostProcessor.renderProcessing(FilterPostProcesso

    r.java:176)

    at com.jme3.post.FilterPostProcessor.renderFilterChain(FilterPostProcess

    or.java:249)

    at com.jme3.post.FilterPostProcessor.postFrame(FilterPostProcessor.java:

    262)

    at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:737

    )

    at com.jme3.renderer.RenderManager.render(RenderManager.java:757)

    at com.jme3.app.SimpleApplication.update(SimpleApplication.java:257)

    at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDispl

    ay.java:143)

    at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:171)

    at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.j

    ava:217)

    at java.lang.Thread.run(Unknown Source)