public ShadowPass( ShadowPassType shadowPassType, Scene scene, Camera camera, DirectionalLight light, RenderTarget renderTarget) { super(scene, camera, 0); mShadowPassType = shadowPassType; mShadowRenderTarget = renderTarget; mShadowMapSize = renderTarget.getWidth(); if (shadowPassType == ShadowPassType.CREATE_SHADOW_MAP) { mShadowMapMaterial = new ShadowMapMaterial(); mShadowMapMaterial.setLight(light); mShadowMapMaterial.setCamera(camera); mShadowMapMaterial.setScene(scene); setMaterial(mShadowMapMaterial); } }
private void addShadowMapMaterialPlugin(Object3D o, ShadowMapMaterialPlugin materialPlugin) { Material m = o.getMaterial(); if (m != null && m.lightingEnabled()) { if (materialPlugin != null) { m.addPlugin(materialPlugin); } else if (mShadowMapMaterial != null) { m.removePlugin(mShadowMapMaterial.getMaterialPlugin()); } } for (int i = 0; i < o.getNumChildren(); i++) addShadowMapMaterialPlugin(o.getChildAt(i), materialPlugin); }
@Override public void render( Scene scene, Renderer renderer, ScreenQuad screenQuad, RenderTarget writeBuffer, RenderTarget readBuffer, long ellapsedTime, double deltaTime) { if (mShadowPassType == ShadowPassType.APPLY_SHADOW_MAP) { mShadowMapMaterial.setShadowMapTexture(mShadowRenderTarget.getTexture()); super.render(scene, renderer, screenQuad, writeBuffer, readBuffer, ellapsedTime, deltaTime); } else { renderer.setOverrideViewportDimensions(mShadowMapSize, mShadowMapSize); super.render( scene, renderer, screenQuad, mShadowRenderTarget, readBuffer, ellapsedTime, deltaTime); renderer.clearOverrideViewportDimensions(); } }