com.jme3.light.LightList Java Examples
The following examples show how to use
com.jme3.light.LightList.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpatialTreeNode.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override @FxThread public @NotNull Array<TreeNode<?>> getChildren(@NotNull final NodeTree<?> nodeTree) { final Array<TreeNode<?>> result = ArrayFactory.newArray(TreeNode.class); final Spatial element = getElement(); final LightList lightList = element.getLocalLightList(); lightList.forEach(light -> { if (!(light instanceof InvisibleObject)) { result.add(FACTORY_REGISTRY.createFor(light)); } }); final int numControls = element.getNumControls(); for (int i = 0; i < numControls; i++) { final Control control = element.getControl(i); result.add(FACTORY_REGISTRY.createFor(control)); } return result; }
Example #2
Source File: Spatial.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
public void read(JmeImporter im) throws IOException { InputCapsule ic = im.getCapsule(this); name = ic.readString("name", null); worldBound = (BoundingVolume) ic.readSavable("world_bound", null); cullHint = ic.readEnum("cull_mode", CullHint.class, CullHint.Inherit); batchHint = ic.readEnum("batch_hint", BatchHint.class, BatchHint.Inherit); queueBucket = ic.readEnum("queue", RenderQueue.Bucket.class, RenderQueue.Bucket.Inherit); shadowMode = ic.readEnum("shadow_mode", ShadowMode.class, ShadowMode.Inherit); localTransform = (Transform) ic.readSavable("transform", Transform.IDENTITY); localLights = (LightList) ic.readSavable("lights", null); localLights.setOwner(this); //changed for backward compatibility with j3o files generated before the AnimControl/SkeletonControl split //the AnimControl creates the SkeletonControl for old files and add it to the spatial. //The SkeletonControl must be the last in the stack so we add the list of all other control before it. //When backward compatibility won't be needed anymore this can be replaced by : //controls = ic.readSavableArrayList("controlsList", null)); controls.addAll(0, ic.readSavableArrayList("controlsList", null)); userData = (HashMap<String, Savable>) ic.readStringSavableMap("user_data", null); }
Example #3
Source File: Technique.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Called by the material to determine which shader to use for rendering. * * The {@link TechniqueDefLogic} is used to determine the shader to use * based on the {@link LightMode}. * * @param renderManager The render manager for which the shader is to be selected. * @param rendererCaps The renderer capabilities which the shader should support. * @return A compatible shader. */ Shader makeCurrent(RenderManager renderManager, SafeArrayList<MatParamOverride> worldOverrides, SafeArrayList<MatParamOverride> forcedOverrides, LightList lights, EnumSet<Caps> rendererCaps) { TechniqueDefLogic logic = def.getLogic(); AssetManager assetManager = owner.getMaterialDef().getAssetManager(); dynamicDefines.clear(); dynamicDefines.setAll(paramDefines); if (worldOverrides != null) { applyOverrides(dynamicDefines, worldOverrides); } if (forcedOverrides != null) { applyOverrides(dynamicDefines, forcedOverrides); } return logic.makeCurrent(assetManager, renderManager, rendererCaps, lights, dynamicDefines); }
Example #4
Source File: SinglePassLightingLogic.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void render(RenderManager renderManager, Shader shader, Geometry geometry, LightList lights, int lastTexUnit) { int nbRenderedLights = 0; Renderer renderer = renderManager.getRenderer(); int batchSize = renderManager.getSinglePassLightBatchSize(); if (lights.size() == 0) { updateLightListUniforms(shader, geometry, lights, batchSize, renderManager, 0); renderer.setShader(shader); renderMeshFromGeometry(renderer, geometry); } else { while (nbRenderedLights < lights.size()) { nbRenderedLights = updateLightListUniforms(shader, geometry, lights, batchSize, renderManager, nbRenderedLights); renderer.setShader(shader); renderMeshFromGeometry(renderer, geometry); } } }
Example #5
Source File: Spatial.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * Constructor instantiates a new <code>Spatial</code> object setting the * rotation, translation and scale value to defaults. * * @param name * the name of the scene element. This is required for * identification and comparison purposes. */ protected Spatial(String name) { this.name = name; this.visible = true; localTransform = new Transform(); worldTransform = new Transform(); localLights = new LightList(this); worldLights = new LightList(this); localOverrides = new SafeArrayList<>(MatParamOverride.class); worldOverrides = new SafeArrayList<>(MatParamOverride.class); refreshFlags |= RF_BOUND; }
Example #6
Source File: Material.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
private ColorRGBA getAmbientColor(LightList lightList) { ambientLightColor.set(0, 0, 0, 1); for (int j = 0; j < lightList.size(); j++) { Light l = lightList.get(j); if (l instanceof AmbientLight) { ambientLightColor.addLocal(l.getColor()); } } ambientLightColor.a = 1.0f; return ambientLightColor; }
Example #7
Source File: Spatial.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * Serialization only. Do not use. */ public Spatial() { localTransform = new Transform(); worldTransform = new Transform(); localLights = new LightList(this); worldLights = new LightList(this); refreshFlags |= RF_BOUND; }
Example #8
Source File: SinglePassLightingLogic.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Shader makeCurrent(AssetManager assetManager, RenderManager renderManager, EnumSet<Caps> rendererCaps, LightList lights, DefineList defines) { defines.set(nbLightsDefineId, renderManager.getSinglePassLightBatchSize() * 3); defines.set(singlePassLightingDefineId, true); return super.makeCurrent(assetManager, renderManager, rendererCaps, lights, defines); }
Example #9
Source File: StaticPassLightingLogic.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void render(RenderManager renderManager, Shader shader, Geometry geometry, LightList lights, int lastTexUnit) { Renderer renderer = renderManager.getRenderer(); Matrix4f viewMatrix = renderManager.getCurrentCamera().getViewMatrix(); updateLightListUniforms(viewMatrix, shader, lights); renderer.setShader(shader); renderMeshFromGeometry(renderer, geometry); }
Example #10
Source File: StaticPassLightingLogic.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Shader makeCurrent(AssetManager assetManager, RenderManager renderManager, EnumSet<Caps> rendererCaps, LightList lights, DefineList defines) { // TODO: if it ever changes that render isn't called // right away with the same geometry after makeCurrent, it would be // a problem. // Do a radix sort. tempDirLights.clear(); tempPointLights.clear(); tempSpotLights.clear(); for (Light light : lights) { switch (light.getType()) { case Directional: tempDirLights.add((DirectionalLight) light); break; case Point: tempPointLights.add((PointLight) light); break; case Spot: tempSpotLights.add((SpotLight) light); break; } } defines.set(numDirLightsDefineId, tempDirLights.size()); defines.set(numPointLightsDefineId, tempPointLights.size()); defines.set(numSpotLightsDefineId, tempSpotLights.size()); return techniqueDef.getShader(assetManager, rendererCaps, defines); }
Example #11
Source File: Spatial.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override @SuppressWarnings("unchecked") public void read(JmeImporter im) throws IOException { InputCapsule ic = im.getCapsule(this); name = ic.readString("name", null); worldBound = (BoundingVolume) ic.readSavable("world_bound", null); cullHint = ic.readEnum("cull_mode", CullHint.class, CullHint.Inherit); batchHint = ic.readEnum("batch_hint", BatchHint.class, BatchHint.Inherit); queueBucket = ic.readEnum("queue", RenderQueue.Bucket.class, RenderQueue.Bucket.Inherit); shadowMode = ic.readEnum("shadow_mode", ShadowMode.class, ShadowMode.Inherit); localTransform = (Transform) ic.readSavable("transform", Transform.IDENTITY); localLights = (LightList) ic.readSavable("lights", null); localLights.setOwner(this); ArrayList<MatParamOverride> localOverridesList = ic.readSavableArrayList("overrides", null); if (localOverridesList == null) { localOverrides = new SafeArrayList<>(MatParamOverride.class); } else { localOverrides = new SafeArrayList(MatParamOverride.class, localOverridesList); } worldOverrides = new SafeArrayList<>(MatParamOverride.class); //changed for backward compatibility with j3o files //generated before the AnimControl/SkeletonControl split //the AnimControl creates the SkeletonControl for old files and add it to the spatial. //The SkeletonControl must be the last in the stack //so we add the list of all other control before it. //When backward compatibility won't be needed anymore this can be replaced by : //controls = ic.readSavableArrayList("controlsList", null)); controls.addAll(0, ic.readSavableArrayList("controlsList", null)); userData = (HashMap<String, Savable>) ic.readStringSavableMap("user_data", null); }
Example #12
Source File: Spatial.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
public void read(JmeImporter im) throws IOException { InputCapsule ic = im.getCapsule(this); name = ic.readString("name", null); worldBound = (BoundingVolume) ic.readSavable("world_bound", null); cullHint = ic.readEnum("cull_mode", CullHint.class, CullHint.Inherit); batchHint = ic.readEnum("batch_hint", BatchHint.class, BatchHint.Inherit); queueBucket = ic.readEnum("queue", RenderQueue.Bucket.class, RenderQueue.Bucket.Inherit); shadowMode = ic.readEnum("shadow_mode", ShadowMode.class, ShadowMode.Inherit); localTransform = (Transform) ic.readSavable("transform", Transform.IDENTITY); localLights = (LightList) ic.readSavable("lights", null); localLights.setOwner(this); ArrayList<MatParamOverride> localOverridesList = ic.readSavableArrayList("overrides", null); if (localOverridesList == null) { localOverrides = new SafeArrayList<>(MatParamOverride.class); } else { localOverrides = new SafeArrayList(MatParamOverride.class, localOverridesList); } worldOverrides = new SafeArrayList<>(MatParamOverride.class); //changed for backward compatibility with j3o files generated before the AnimControl/SkeletonControl split //the AnimControl creates the SkeletonControl for old files and add it to the spatial. //The SkeletonControl must be the last in the stack so we add the list of all other control before it. //When backward compatibility won't be needed anymore this can be replaced by : //controls = ic.readSavableArrayList("controlsList", null)); controls.addAll(0, ic.readSavableArrayList("controlsList", null)); userData = (HashMap<String, Savable>) ic.readStringSavableMap("user_data", null); }
Example #13
Source File: Spatial.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Constructor instantiates a new <code>Spatial</code> object setting the * rotation, translation and scale value to defaults. * * @param name * the name of the scene element. This is required for * identification and comparison purposes. */ protected Spatial(String name) { this.name = name; localTransform = new Transform(); worldTransform = new Transform(); localLights = new LightList(this); worldLights = new LightList(this); localOverrides = new SafeArrayList<>(MatParamOverride.class); worldOverrides = new SafeArrayList<>(MatParamOverride.class); refreshFlags |= RF_BOUND; }
Example #14
Source File: JoglRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public void setLighting(LightList list) { if (list == null || list.size() == 0) { // turn off lighting gl.glDisable(gl.GL_LIGHTING); return; } gl.glEnable(gl.GL_LIGHTING); gl.glShadeModel(gl.GL_SMOOTH); float[] temp = new float[4]; // reset model view to specify // light positions in world space // instead of model space // gl.glPushMatrix(); // gl.glLoadIdentity(); for (int i = 0; i < list.size() + 1; i++) { int lightId = gl.GL_LIGHT0 + i; if (list.size() <= i) { // goes beyond the num lights we need // disable it gl.glDisable(lightId); break; } Light l = list.get(i); if (!l.isEnabled()) { gl.glDisable(lightId); continue; } ColorRGBA color = l.getColor(); color.toArray(temp); gl.glEnable(lightId); gl.glLightfv(lightId, gl.GL_DIFFUSE, temp, 0); gl.glLightfv(lightId, gl.GL_SPECULAR, temp, 0); ColorRGBA.Black.toArray(temp); gl.glLightfv(lightId, gl.GL_AMBIENT, temp, 0); switch (l.getType()) { case Directional: DirectionalLight dl = (DirectionalLight) l; dl.getDirection().toArray(temp); temp[3] = 0f; // marks to GL its a directional light gl.glLightfv(lightId, gl.GL_POSITION, temp, 0); break; case Point: PointLight pl = (PointLight) l; pl.getPosition().toArray(temp); temp[3] = 1f; // marks to GL its a point light gl.glLightfv(lightId, gl.GL_POSITION, temp, 0); break; } } // restore modelview to original value // gl.glPopMatrix(); }
Example #15
Source File: NullRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public void setLighting(LightList lights) { }
Example #16
Source File: Material.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
/** * Uploads the lights in the light list as two uniform arrays.<br/><br/> * * <p> * <code>uniform vec4 g_LightColor[numLights];</code><br/> * // g_LightColor.rgb is the diffuse/specular color of the light.<br/> * // g_Lightcolor.a is the type of light, 0 = Directional, 1 = Point, <br/> * // 2 = Spot. <br/> * <br/> * <code>uniform vec4 g_LightPosition[numLights];</code><br/> * // g_LightPosition.xyz is the position of the light (for point lights)<br/> * // or the direction of the light (for directional lights).<br/> * // g_LightPosition.w is the inverse radius (1/r) of the light (for attenuation) <br/> * </p> */ protected void updateLightListUniforms(Shader shader, Geometry g, int numLights) { if (numLights == 0) { // this shader does not do lighting, ignore. return; } LightList lightList = g.getWorldLightList(); Uniform lightColor = shader.getLightColorUniform(); Uniform lightPos = shader.getLightPositionUniform(); Uniform lightDir = shader.getLightDirectionUniform(); lightColor.setVector4Length(numLights); lightPos.setVector4Length(numLights); lightDir.setVector4Length(numLights); Uniform ambientColor = shader.getAmbientColorUniform(); ambientColor.setValue(VarType.Vector4, getAmbientColor(lightList)); int lightIndex = 0; for (int i = 0; i < numLights; i++) { if (lightList.size() <= i) { lightColor.setVector4InArray(0f, 0f, 0f, 0f, lightIndex); lightPos.setVector4InArray(0f, 0f, 0f, 0f, lightIndex); } else { Light l = lightList.get(i); ColorRGBA color = l.getColor(); lightColor.setVector4InArray(color.getRed(), color.getGreen(), color.getBlue(), l.getType().getId(), i); switch (l.getType()) { case Directional: DirectionalLight dl = (DirectionalLight) l; Vector3f dir = dl.getDirection(); lightPos.setVector4InArray(dir.getX(), dir.getY(), dir.getZ(), -1, lightIndex); break; case Point: PointLight pl = (PointLight) l; Vector3f pos = pl.getPosition(); float invRadius = pl.getInvRadius(); lightPos.setVector4InArray(pos.getX(), pos.getY(), pos.getZ(), invRadius, lightIndex); break; case Spot: SpotLight sl = (SpotLight) l; Vector3f pos2 = sl.getPosition(); Vector3f dir2 = sl.getDirection(); float invRange = sl.getInvSpotRange(); float spotAngleCos = sl.getPackedAngleCos(); lightPos.setVector4InArray(pos2.getX(), pos2.getY(), pos2.getZ(), invRange, lightIndex); lightDir.setVector4InArray(dir2.getX(), dir2.getY(), dir2.getZ(), spotAngleCos, lightIndex); break; case Ambient: // skip this light. Does not increase lightIndex continue; default: throw new UnsupportedOperationException("Unknown type of light: " + l.getType()); } } lightIndex++; } while (lightIndex < numLights) { lightColor.setVector4InArray(0f, 0f, 0f, 0f, lightIndex); lightPos.setVector4InArray(0f, 0f, 0f, 0f, lightIndex); lightIndex++; } }
Example #17
Source File: LwjglRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public void setLighting(LightList list) { }
Example #18
Source File: JoglRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public void setLighting(LightList list) { if (glslVer == -1) { GL gl = GLContext.getCurrentGL(); if (list == null || list.size() == 0) { // turn off lighting gl.glDisable(GLLightingFunc.GL_LIGHTING); return; } gl.glEnable(GLLightingFunc.GL_LIGHTING); gl.getGL2().glShadeModel(GLLightingFunc.GL_SMOOTH); float[] temp = new float[4]; // reset model view to specify // light positions in world space // instead of model space // gl.glPushMatrix(); // gl.glLoadIdentity(); for (int i = 0; i < list.size() + 1; i++) { int lightId = GLLightingFunc.GL_LIGHT0 + i; if (list.size() <= i) { // goes beyond the num lights we need // disable it gl.glDisable(lightId); break; } Light l = list.get(i); if (!l.isEnabled()) { gl.glDisable(lightId); continue; } ColorRGBA color = l.getColor(); color.toArray(temp); gl.glEnable(lightId); gl.getGL2().glLightfv(lightId, GLLightingFunc.GL_DIFFUSE, temp, 0); gl.getGL2().glLightfv(lightId, GLLightingFunc.GL_SPECULAR, temp, 0); ColorRGBA.Black.toArray(temp); gl.getGL2().glLightfv(lightId, GLLightingFunc.GL_AMBIENT, temp, 0); switch (l.getType()) { case Directional: DirectionalLight dl = (DirectionalLight) l; dl.getDirection().toArray(temp); temp[3] = 0f; // marks to GL its a directional light gl.getGL2().glLightfv(lightId, GLLightingFunc.GL_POSITION, temp, 0); break; case Point: PointLight pl = (PointLight) l; pl.getPosition().toArray(temp); temp[3] = 1f; // marks to GL its a point light gl.getGL2().glLightfv(lightId, GLLightingFunc.GL_POSITION, temp, 0); break; } } // restore modelview to original value // gl.glPopMatrix(); } }
Example #19
Source File: OGLESShaderRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public void setLighting(LightList list) { }
Example #20
Source File: GdxRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public void setLighting(LightList list) { }
Example #21
Source File: NullRenderer.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void setLighting(LightList lights) { }
Example #22
Source File: RenderManager.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Renders the given geometry. * <p> * First the proper world matrix is set, if * the geometry's {@link Geometry#setIgnoreTransform(boolean) ignore transform} * feature is enabled, the identity world matrix is used, otherwise, the * geometry's {@link Geometry#getWorldMatrix() world transform matrix} is used. * <p> * Once the world matrix is applied, the proper material is chosen for rendering. * If a {@link #setForcedMaterial(com.jme3.material.Material) forced material} is * set on this RenderManager, then it is used for rendering the geometry, * otherwise, the {@link Geometry#getMaterial() geometry's material} is used. * <p> * If a {@link #setForcedTechnique(java.lang.String) forced technique} is * set on this RenderManager, then it is selected automatically * on the geometry's material and is used for rendering. Otherwise, one * of the {@link com.jme3.material.MaterialDef#getTechniqueDefsNames() default techniques} is * used. * <p> * If a {@link #setForcedRenderState(com.jme3.material.RenderState) forced * render state} is set on this RenderManager, then it is used * for rendering the material, and the material's own render state is ignored. * Otherwise, the material's render state is used as intended. * * @param geom The geometry to render * * @see Technique * @see RenderState * @see com.jme3.material.Material#selectTechnique(java.lang.String, com.jme3.renderer.RenderManager) * @see com.jme3.material.Material#render(com.jme3.scene.Geometry, com.jme3.renderer.RenderManager) */ public void renderGeometry(Geometry geom) { if (geom.isIgnoreTransform()) { setWorldMatrix(Matrix4f.IDENTITY); } else { setWorldMatrix(geom.getWorldMatrix()); } // Perform light filtering if we have a light filter. LightList lightList = geom.getWorldLightList(); if (lightFilter != null) { filteredLightList.clear(); lightFilter.filterLights(geom, filteredLightList); lightList = filteredLightList; } Material material = geom.getMaterial(); //if forcedTechnique we try to force it for render, //if it does not exists in the mat def, we check for forcedMaterial and render the geom if not null //else the geom is not rendered if (forcedTechnique != null) { MaterialDef matDef = material.getMaterialDef(); if (matDef.getTechniqueDefs(forcedTechnique) != null) { Technique activeTechnique = material.getActiveTechnique(); String previousTechniqueName = activeTechnique != null ? activeTechnique.getDef().getName() : TechniqueDef.DEFAULT_TECHNIQUE_NAME; geom.getMaterial().selectTechnique(forcedTechnique, this); //saving forcedRenderState for future calls RenderState tmpRs = forcedRenderState; if (geom.getMaterial().getActiveTechnique().getDef().getForcedRenderState() != null) { //forcing forced technique renderState forcedRenderState = geom.getMaterial().getActiveTechnique().getDef().getForcedRenderState(); } // use geometry's material material.render(geom, lightList, this); material.selectTechnique(previousTechniqueName, this); //restoring forcedRenderState forcedRenderState = tmpRs; //Reverted this part from revision 6197 //If forcedTechnique does not exists, and forcedMaterial is not set, the geom MUST NOT be rendered } else if (forcedMaterial != null) { // use forced material forcedMaterial.render(geom, lightList, this); } } else if (forcedMaterial != null) { // use forced material forcedMaterial.render(geom, lightList, this); } else { material.render(geom, lightList, this); } }
Example #23
Source File: Material.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 3 votes |
/** * Called by {@link RenderManager} to render the geometry by * using this material. * <p> * The material is rendered as follows: * <ul> * <li>Determine which technique to use to render the material - * either what the user selected via * {@link #selectTechnique(java.lang.String, com.jme3.renderer.RenderManager) * Material.selectTechnique()}, * or the first default technique that the renderer supports * (based on the technique's {@link TechniqueDef#getRequiredCaps() requested rendering capabilities})<ul> * <li>If the technique has been changed since the last frame, then it is notified via * {@link Technique#makeCurrent(com.jme3.renderer.RenderManager, com.jme3.util.SafeArrayList, com.jme3.util.SafeArrayList, com.jme3.light.LightList, java.util.EnumSet) * Technique.makeCurrent()}. * If the technique wants to use a shader to render the model, it should load it at this part - * the shader should have all the proper defines as declared in the technique definition, * including those that are bound to material parameters. * The technique can re-use the shader from the last frame if * no changes to the defines occurred.</li></ul> * <li>Set the {@link RenderState} to use for rendering. The render states are * applied in this order (later RenderStates override earlier RenderStates):<ol> * <li>{@link TechniqueDef#getRenderState() Technique Definition's RenderState} * - i.e. specific renderstate that is required for the shader.</li> * <li>{@link #getAdditionalRenderState() Material Instance Additional RenderState} * - i.e. ad-hoc renderstate set per model</li> * <li>{@link RenderManager#getForcedRenderState() RenderManager's Forced RenderState} * - i.e. renderstate requested by a {@link com.jme3.post.SceneProcessor} or * post-processing filter.</li></ol> * <li>If the technique uses a shader, then the uniforms of the shader must be updated.<ul> * <li>Uniforms bound to material parameters are updated based on the current material parameter values.</li> * <li>Uniforms bound to world parameters are updated from the RenderManager. * Internally {@link UniformBindingManager} is used for this task.</li> * <li>Uniforms bound to textures will cause the texture to be uploaded as necessary. * The uniform is set to the texture unit where the texture is bound.</li></ul> * <li>If the technique uses a shader, the model is then rendered according * to the lighting mode specified on the technique definition.<ul> * <li>{@link LightMode#SinglePass single pass light mode} fills the shader's light uniform arrays * with the first 4 lights and renders the model once.</li> * <li>{@link LightMode#MultiPass multi pass light mode} light mode renders the model multiple times, * for the first light it is rendered opaque, on subsequent lights it is * rendered with {@link BlendMode#AlphaAdditive alpha-additive} blending and depth writing disabled.</li> * </ul> * <li>For techniques that do not use shaders, * fixed function OpenGL is used to render the model (see {@link com.jme3.renderer.opengl.GLRenderer} interface):<ul> * <li>OpenGL state that is bound to material parameters is updated. </li> * <li>The texture set on the material is uploaded and bound. * Currently only 1 texture is supported for fixed function techniques.</li> * <li>If the technique uses lighting, then OpenGL lighting state is updated * based on the light list on the geometry, otherwise OpenGL lighting is disabled.</li> * <li>The mesh is uploaded and rendered.</li> * </ul> * </ul> * * @param geometry The geometry to render * @param lights Presorted and filtered light list to use for rendering * @param renderManager The render manager requesting the rendering */ public void render(Geometry geometry, LightList lights, RenderManager renderManager) { if (technique == null) { selectTechnique(TechniqueDef.DEFAULT_TECHNIQUE_NAME, renderManager); } TechniqueDef techniqueDef = technique.getDef(); Renderer renderer = renderManager.getRenderer(); EnumSet<Caps> rendererCaps = renderer.getCaps(); if (techniqueDef.isNoRender()) { return; } // Apply render state updateRenderState(renderManager, renderer, techniqueDef); // Get world overrides SafeArrayList<MatParamOverride> overrides = geometry.getWorldMatParamOverrides(); // Select shader to use Shader shader = technique.makeCurrent(renderManager, overrides, renderManager.getForcedMatParams(), lights, rendererCaps); // Begin tracking which uniforms were changed by material. clearUniformsSetByCurrent(shader); // Set uniform bindings renderManager.updateUniformBindings(shader); // Set material parameters int unit = updateShaderMaterialParameters(renderer, shader, overrides, renderManager.getForcedMatParams()); // Clear any uniforms not changed by material. resetUniformsNotSetByCurrent(shader); // Delegate rendering to the technique technique.render(renderManager, shader, geometry, lights, unit); }
Example #24
Source File: Technique.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Render the technique according to its {@link TechniqueDefLogic}. * * @param renderManager The render manager to perform the rendering against. * @param shader The shader that was selected in * {@link #makeCurrent(com.jme3.renderer.RenderManager, java.util.EnumSet)}. * @param geometry The geometry to render * @param lights Lights which influence the geometry. */ void render(RenderManager renderManager, Shader shader, Geometry geometry, LightList lights, int lastTexUnit) { TechniqueDefLogic logic = def.getLogic(); logic.render(renderManager, shader, geometry, lights, lastTexUnit); }
Example #25
Source File: Spatial.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Returns the local {@link LightList}, which are the lights * that were directly attached to this <code>Spatial</code> through the * {@link #addLight(com.jme3.light.Light) } and * {@link #removeLight(com.jme3.light.Light) } methods. * * @return The local light list */ public LightList getLocalLightList() { return localLights; }
Example #26
Source File: Renderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 2 votes |
/** * Set lighting state. * Does nothing if the renderer is shader based. * The lights should be provided in world space. * Specify <code>null</code> to disable lighting. * * @param lights The light list to set. */ public void setLighting(LightList lights);
Example #27
Source File: Spatial.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Returns the world {@link LightList}, containing the lights * combined from all this <code>Spatial's</code> parents up to and including * this <code>Spatial</code>'s lights. * * @return The combined world light list */ public LightList getWorldLightList() { return worldLights; }
Example #28
Source File: Spatial.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 2 votes |
/** * Returns the local {@link LightList}, which are the lights * that were directly attached to this <code>Spatial</code> through the * {@link #addLight(com.jme3.light.Light) } and * {@link #removeLight(com.jme3.light.Light) } methods. * * @return The local light list */ public LightList getLocalLightList() { return localLights; }
Example #29
Source File: Spatial.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 2 votes |
/** * Returns the world {@link LightList}, containing the lights * combined from all this <code>Spatial's</code> parents up to and including * this <code>Spatial</code>'s lights. * * @return The combined world light list */ public LightList getWorldLightList() { return worldLights; }
Example #30
Source File: Spatial.java From jmonkeybuilder with Apache License 2.0 | 2 votes |
/** * Returns the world {@link LightList}, containing the lights * combined from all this <code>Spatial's</code> parents up to and including * this <code>Spatial</code>'s lights. * * @return The combined world light list */ public LightList getWorldLightList() { return worldLights; }