Ejemplo n.º 1
0
  public void postQueue(RenderQueue rq) {
    GeometryList occluders = rq.getShadowQueueContent(ShadowMode.Cast);
    if (occluders.size() == 0) {
      noOccluders = true;
      return;
    } else {
      noOccluders = false;
    }

    GeometryList receivers = rq.getShadowQueueContent(ShadowMode.Receive);

    // update frustum points based on current camera
    Camera viewCam = viewPort.getCamera();
    ShadowUtil.updateFrustumPoints(
        viewCam, viewCam.getFrustumNear(), viewCam.getFrustumFar(), 1.0f, points);

    Vector3f frustaCenter = new Vector3f();
    for (Vector3f point : points) {
      frustaCenter.addLocal(point);
    }
    frustaCenter.multLocal(1f / 8f);

    // update light direction
    shadowCam.setProjectionMatrix(null);
    shadowCam.setParallelProjection(true);
    //        shadowCam.setFrustumPerspective(45, 1, 1, 20);

    shadowCam.lookAtDirection(direction, Vector3f.UNIT_Y);
    shadowCam.update();
    shadowCam.setLocation(frustaCenter);
    shadowCam.update();
    shadowCam.updateViewProjection();

    // render shadow casters to shadow map
    ShadowUtil.updateShadowCamera(occluders, receivers, shadowCam, points);

    Renderer r = renderManager.getRenderer();
    renderManager.setCamera(shadowCam, false);
    renderManager.setForcedMaterial(preshadowMat);

    r.setFrameBuffer(shadowFB);
    r.clearBuffers(false, true, false);
    viewPort.getQueue().renderShadowQueue(ShadowMode.Cast, renderManager, shadowCam, true);
    r.setFrameBuffer(viewPort.getOutputFrameBuffer());

    renderManager.setForcedMaterial(null);
    renderManager.setCamera(viewCam, false);
  }
  public void postQueue(RenderQueue rq) {
    Camera sceneCam = rm.getCurrentCamera();

    // update refraction cam
    refractionCam.setLocation(sceneCam.getLocation());
    refractionCam.setRotation(sceneCam.getRotation());
    refractionCam.setFrustum(
        sceneCam.getFrustumNear(),
        sceneCam.getFrustumFar(),
        sceneCam.getFrustumLeft(),
        sceneCam.getFrustumRight(),
        sceneCam.getFrustumTop(),
        sceneCam.getFrustumBottom());
    refractionCam.setParallelProjection(sceneCam.isParallelProjection());

    // update reflection cam
    WaterUtils.updateReflectionCam(reflectionCam, plane, sceneCam);

    // Rendering reflection and refraction
    rm.renderViewPort(reflectionView, savedTpf);
    rm.renderViewPort(refractionView, savedTpf);
    rm.getRenderer().setFrameBuffer(vp.getOutputFrameBuffer());
    rm.setCamera(sceneCam, false);
  }