Shadow help

i have been working on shadow mapping, I started out going to big to fast so i made a simple shadow map that is suppose to map from one point (10,10,10) i don’t really know what the problem is I just know it isn’t working.  Just to be clear the black square stays in the middle of the screen don’t know why.



picture of what is going on





here is code


package shadow;
 
import org.lwjgl.opengl.ARBShadow;
import org.lwjgl.opengl.GL11;

import com.jme.app.BaseGame;
import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingBox;
import com.jme.image.Texture;
import com.jme.light.DirectionalLight;
import com.jme.light.PointLight;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.TextureRenderer;
import com.jme.scene.shape.Box;
import com.jme.scene.shape.Sphere;
import com.jme.scene.state.GLSLShaderObjectsState;
import com.jme.scene.state.LightState;

public class simpleShadowMap extends SimpleGame {
   
   public static void main(String args[]){
      simpleShadowMap app = new simpleShadowMap();
      app.setDialogBehaviour(BaseGame.ALWAYS_SHOW_PROPS_DIALOG);
      app.start();
   }

   protected void simpleInitGame() {
      TextureRenderer tr = display.createTextureRenderer(512,512,false,false,true,false,TextureRenderer.RENDER_TEXTURE_2D,0);
      
      
      Texture shadowMap = new Texture();
      shadowMap.setRTTSource(Texture.RTT_SOURCE_DEPTH);
      
      Box b = new Box();
      b.setDefaultColor(ColorRGBA.red);
      b.setData(new Vector3f(0,0,0),3,3,3);
      b.setModelBound(new BoundingBox());
      rootNode.attachChild(b);
      
      Box q = new Box();
      q.setDefaultColor(ColorRGBA.blue);
      q.setData(new Vector3f(0,-3,0),10,0,10);
      rootNode.attachChild(q);
      
      GLSLShaderObjectsState shader = display.getRenderer().createGLSLShaderObjectsState();
      
      
      LightState ls = display.getRenderer().createLightState();
      ls.detachAll();
      
      PointLight sl = new PointLight();
      sl.setLocation(new Vector3f(10,10,10));
      sl.setEnabled(true);
      ls.attach(sl);
      
      DirectionalLight dl = new DirectionalLight();
      dl.setDirection(new Vector3f(0,0,0));
      dl.setEnabled(true);
      ls.attach(dl);
      

      Sphere s = new Sphere("light");
      s.setData(new Vector3f(13,13,13),10,10,3);
      
      rootNode.attachChild(s);
      
      rootNode.setRenderState(ls);
      //Debugger.drawBuffer(Texture.RTT_SOURCE_DEPTH, Debugger.NORTHEAST, display.getRenderer());
      

         tr.setupTexture(shadowMap);
         tr.getCamera().setLocation(new Vector3f(10,10,10));
         tr.getCamera().lookAt(new Vector3f(0,0,0),new Vector3f(0,1,0));
         tr.updateCamera();
         tr.render(rootNode,shadowMap);
         
           shader.load(simpleShadowMap.class.getResource("ShadowMapping.vert"),simpleShadowMap.class.getResource("ShadowMapping.frag"));
      shader.setUniform("shadowMap",shadowMap.getTextureId());
         GL11.glTexParameteri(GL11.GL_TEXTURE_2D,ARBShadow.GL_TEXTURE_COMPARE_MODE_ARB,ARBShadow.GL_COMPARE_R_TO_TEXTURE_ARB);
         GL11.glTexParameteri(GL11.GL_TEXTURE_2D,ARBShadow.GL_TEXTURE_COMPARE_FUNC_ARB,GL11.GL_LEQUAL);
         
      shader.relinkProgram();
      shader.setEnabled(true);
         
      rootNode.setRenderState(shader);   
   }

}



Shader vertex code


varying vec4 projCoord;

void main()
{
   vec4 realPos = gl_ModelViewMatrix * gl_Vertex;
 
   projCoord = gl_TextureMatrix[0] * realPos;
   gl_FrontColor = gl_Color;

   gl_Position = ftransform();
}


Shader fragment code


uniform sampler2DShadow shadowMap;
varying vec4 projCoord;

void main ()
{
   const float kTransparency = 0.3;
   vec4 color = gl_Color;

   float rValue = shadow2DProj(shadowMap, projCoord).r + kTransparency;
   rValue = clamp(rValue, 0.0, 1.0);

   vec3 coordPos  = projCoord.xyz / projCoord.w;

   if(coordPos.x >= 0.0 && coordPos.y >= 0.0 && coordPos.x <= 1.0 && coordPos.y <= 1.0 )
      {
      gl_FragColor = color * rValue;
   }
   else
   {
      gl_FragColor = color;
   }
}


I will probably be corrected, but think you need to assign material states to youre boxes

could you expand on why?  I'll give it a try

Materials allow light absorbtion and defraction

no that is a example of the shadow already put in jme, I wrote a shadow mapping thing it uses off screen rendering to get the depth texture from the lights pos and then you render from the eyes position and compare the lights view to the eyes view to see what is in shadow.  It is so straight forward(the code) I can't see why it won't work.

help anyone? :?