コード例 #1
0
ファイル: WaterNode.java プロジェクト: gouessej/Ardor3D
  /**
   * Initialize texture renderers. Load water textures. Create shaders.
   *
   * @param r
   */
  private void initialize(final Renderer r) {
    if (cam == null || initialized) {
      return;
    }
    initialized = true;

    final ContextCapabilities caps = ContextManager.getCurrentContext().getCapabilities();

    if (useRefraction && useProjectedShader && caps.getNumberOfFragmentTextureUnits() < 6
        || useRefraction && caps.getNumberOfFragmentTextureUnits() < 5) {
      useRefraction = false;
      logger.info("Not enough textureunits, falling back to non refraction water");
    }

    if (!caps.isGLSLSupported()) {
      supported = false;
    }
    if (!(caps.isPbufferSupported() || caps.isFBOSupported())) {
      supported = false;
    }

    if (isSupported()) {
      tRenderer =
          TextureRendererFactory.INSTANCE.createTextureRenderer( //
              cam.getWidth() / renderScale, // width
              cam.getHeight() / renderScale, // height
              8, // Depth bits... TODO: Make configurable?
              0, // Samples... TODO: Make configurable?
              r,
              caps);

      // blurSampleDistance = 1f / ((float) cam.getHeight() / renderScale);

      tRenderer.setMultipleTargets(true);
      tRenderer.setBackgroundColor(new ColorRGBA(0.0f, 0.0f, 0.0f, 1.0f));
      tRenderer
          .getCamera()
          .setFrustum(
              cam.getFrustumNear(),
              cam.getFrustumFar(),
              cam.getFrustumLeft(),
              cam.getFrustumRight(),
              cam.getFrustumTop(),
              cam.getFrustumBottom());

      textureState = new TextureState();
      textureState.setEnabled(true);

      setupTextures();

      fullScreenQuad = new Quad("FullScreenQuad", cam.getWidth() / 4, cam.getHeight() / 4);
      fullScreenQuad.setTranslation(cam.getWidth() / 2, cam.getHeight() / 2, 0);
      fullScreenQuad.getSceneHints().setRenderBucketType(RenderBucketType.Ortho);
      fullScreenQuad.getSceneHints().setCullHint(CullHint.Never);
      fullScreenQuad.getSceneHints().setTextureCombineMode(TextureCombineMode.Replace);
      fullScreenQuad.getSceneHints().setLightCombineMode(LightCombineMode.Off);
      final TextureState ts = new TextureState();
      ts.setTexture(textureReflect);
      fullScreenQuad.setRenderState(ts);
      fullScreenQuad.setRenderState(blurShaderVertical);
      fullScreenQuad.updateWorldRenderStates(false);
    }

    if (!isSupported()) {
      createFallbackData();
    } else {
      noFog = new FogState();
      noFog.setEnabled(false);
    }

    getSceneHints().setCullHint(CullHint.Never);

    setWaterEffectOnSpatial(this);
  }
コード例 #2
0
/**