com.jme3.renderer.Caps Java Examples
The following examples show how to use
com.jme3.renderer.Caps.
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: PreNormalCaching.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Get pre-normals from the given rendering. * @param renderManager the render manager. * @param normalPass the normal pass. * @param viewPort the viewport. */ public static void getPreNormals(RenderManager renderManager, Pass normalPass, ViewPort viewPort) { curCount++; // do we already have a valid cache to set the framebuffer to? Renderer r = renderManager.getRenderer(); if( cachedPreNormals != null ) { r.copyFrameBuffer(cachedPreNormals, normalPass.getRenderFrameBuffer(), false); } else { // lets make the prenormals r.setFrameBuffer(normalPass.getRenderFrameBuffer()); renderManager.getRenderer().clearBuffers(true, true, true); if( renderManager.getRenderer().getCaps().contains(Caps.GLSL150) ) { renderManager.setForcedTechnique("PreNormalPass15"); } else { renderManager.setForcedTechnique("PreNormalPass"); } renderManager.renderViewPortQueues(viewPort, false); renderManager.setForcedTechnique(null); // if we should cache this, do it now if( lastNormalPassesCount > 1 ) { cachedPreNormals = normalPass.getRenderFrameBuffer(); } } renderManager.getRenderer().setFrameBuffer(viewPort.getOutputFrameBuffer()); }
Example #2
Source File: TechniqueDef.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Sets the shaders that this technique definition will use. * * @param shaderNames EnumMap containing all shader names for this stage * @param shaderLanguages EnumMap containing all shader languages for this stage */ public void setShaderFile(EnumMap<Shader.ShaderType, String> shaderNames, EnumMap<Shader.ShaderType, String> shaderLanguages) { requiredCaps.clear(); weight = 0; for (Shader.ShaderType shaderType : shaderNames.keySet()) { String language = shaderLanguages.get(shaderType); String shaderFile = shaderNames.get(shaderType); this.shaderLanguages.put(shaderType, language); this.shaderNames.put(shaderType, shaderFile); Caps cap = Caps.valueOf(language); requiredCaps.add(cap); weight = Math.max(weight, cap.ordinal()); if (shaderType.equals(Shader.ShaderType.Geometry)) { requiredCaps.add(Caps.GeometryShader); } else if (shaderType.equals(Shader.ShaderType.TessellationControl)) { requiredCaps.add(Caps.TesselationShader); } } }
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: Material.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Preloads this material for the given render manager. * <p> * Preloading the material can ensure that when the material is first * used for rendering, there won't be any delay since the material has * been already been setup for rendering. * * @param renderManager The render manager to preload for */ public void preload(RenderManager renderManager, Geometry geometry) { 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; } // Get world overrides SafeArrayList<MatParamOverride> overrides = geometry.getWorldMatParamOverrides(); Shader shader = technique.makeCurrent(renderManager, overrides, null, null, rendererCaps); updateShaderMaterialParameters(renderer, shader, overrides, null); renderManager.getRenderer().setShader(shader); }
Example #5
Source File: ShaderCheck.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
private static void checkMatDef(String matdefName) { MaterialDef def = (MaterialDef) assetManager.loadAsset(matdefName); EnumSet<Caps> rendererCaps = EnumSet.noneOf(Caps.class); rendererCaps.add(Caps.GLSL100); for (TechniqueDef techDef : def.getTechniqueDefs(TechniqueDef.DEFAULT_TECHNIQUE_NAME)) { DefineList defines = techDef.createDefineList(); Shader shader = techDef.getShader(assetManager, rendererCaps, defines); for (Validator validator : validators) { StringBuilder sb = new StringBuilder(); validator.validate(shader, sb); System.out.println("==== Validator: " + validator.getName() + " " + validator.getInstalledVersion() + " ===="); System.out.println(sb.toString()); } } throw new UnsupportedOperationException(); }
Example #6
Source File: TextureUtil.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void initialize(EnumSet<Caps> caps) { supportUnpackRowLength = caps.contains(Caps.UnpackRowLength); this.formats = GLImageFormats.getFormatsForCaps(caps); if (logger.isLoggable(Level.FINE)) { StringBuilder sb = new StringBuilder(); sb.append("Supported texture formats: \n"); for (int i = 0; i < Format.values().length; i++) { Format format = Format.values()[i]; if (formats[0][i] != null) { boolean srgb = formats[1][i] != null; sb.append("\t").append(format.toString()); sb.append(" (Linear"); if (srgb) sb.append("/sRGB"); sb.append(")\n"); } } logger.log(Level.FINE, sb.toString()); } }
Example #7
Source File: TestEverything.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
public void setupHdr(){ if (renderer.getCaps().contains(Caps.GLSL100)){ hdrRender = new HDRRenderer(assetManager, renderer); hdrRender.setMaxIterations(40); hdrRender.setSamples(settings.getSamples()); hdrRender.setWhiteLevel(3); hdrRender.setExposure(0.72f); hdrRender.setThrottle(1); // setPauseOnLostFocus(false); // new HDRConfig(hdrRender).setVisible(true); viewPort.addProcessor(hdrRender); } }
Example #8
Source File: MaterialTest.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void supportGlsl(int version) { switch (version) { case 150: myCaps.add(Caps.GLSL150); case 140: myCaps.add(Caps.GLSL140); case 130: myCaps.add(Caps.GLSL130); case 120: myCaps.add(Caps.GLSL120); case 110: myCaps.add(Caps.GLSL110); case 100: myCaps.add(Caps.GLSL100); break; } }
Example #9
Source File: KTXLoader.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * returns the JME image format from gl formats and types. * @param glFormat * @param glInternalFormat * @param glType * @return */ private Image.Format getImageFormat(int glFormat, int glInternalFormat, int glType) { EnumSet<Caps> caps = EnumSet.allOf(Caps.class); GLImageFormat[][] formats = GLImageFormats.getFormatsForCaps(caps); for (GLImageFormat[] format : formats) { for (int j = 0; j < format.length; j++) { GLImageFormat glImgFormat = format[j]; if (glImgFormat != null) { if (glImgFormat.format == glFormat && glImgFormat.dataType == glType) { if (glFormat == glInternalFormat || glImgFormat.internalFormat == glInternalFormat) { return Image.Format.values()[j]; } } } } } return null; }
Example #10
Source File: MaterialTest.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testSelectNamedTechnique_GLSL150Cap() { supportGlsl(150); material("Common/MatDefs/Light/Lighting.j3md"); material.selectTechnique("PostShadow", renderManager); checkRequiredCaps(Caps.GLSL150); }
Example #11
Source File: MaterialTest.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testSelectDefaultTechnique_GLSL100Cap_MultipleLangs() { supportGlsl(100); material("Common/MatDefs/Misc/Particle.j3md"); material.selectTechnique("Default", renderManager); checkRequiredCaps(Caps.GLSL100); }
Example #12
Source File: MaterialTest.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testSelectDefaultTechnique_GLSL120Cap_MultipleLangs() { supportGlsl(120); material("Common/MatDefs/Misc/Particle.j3md"); material.selectTechnique("Default", renderManager); checkRequiredCaps(Caps.GLSL100, Caps.GLSL120); }
Example #13
Source File: MaterialTest.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testSelectDefaultTechnique_GLSL150Cap() { supportGlsl(150); material("Common/MatDefs/Gui/Gui.j3md"); material.selectTechnique("Default", renderManager); checkRequiredCaps(Caps.GLSL150); }
Example #14
Source File: HDRRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public HDRRenderer(AssetManager manager, Renderer renderer){ this.manager = manager; this.renderer = renderer; Collection<Caps> caps = renderer.getCaps(); if (caps.contains(Caps.PackedFloatColorBuffer)) bufFormat = Format.RGB111110F; else if (caps.contains(Caps.FloatColorBuffer)) bufFormat = Format.RGB16F; else{ enabled = false; return; } }
Example #15
Source File: MaterialTest.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testSelectDefaultTechnique_GLSL100Cap() { supportGlsl(100); material("Common/MatDefs/Gui/Gui.j3md"); material.selectTechnique("Default", renderManager); checkRequiredCaps(Caps.GLSL100); }
Example #16
Source File: MaterialTest.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testSelectNamedTechnique_GLSL100Cap() { supportGlsl(100); material("Common/MatDefs/Light/Lighting.j3md"); material.selectTechnique("PostShadow", renderManager); checkRequiredCaps(Caps.GLSL100); }
Example #17
Source File: MaterialTest.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void checkRequiredCaps(Caps... caps) { EnumSet<Caps> expected = EnumSet.noneOf(Caps.class); expected.addAll(Arrays.asList(caps)); Technique tech = material.getActiveTechnique(); assertEquals(expected, tech.getDef().getRequiredCaps()); }
Example #18
Source File: J3MLoaderTest.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void multipleSameNamedTechniques_shouldBeSupported() throws IOException { when(assetInfo.openStream()).thenReturn(J3MLoader.class.getResourceAsStream("/same-name-technique.j3md")); MaterialDef def = (MaterialDef) j3MLoader.load(assetInfo); assertEquals(2, def.getTechniqueDefs("Test").size()); assertEquals(EnumSet.of(Caps.GLSL150), def.getTechniqueDefs("Test").get(0).getRequiredCaps()); assertEquals(EnumSet.of(Caps.GLSL100), def.getTechniqueDefs("Test").get(1).getRequiredCaps()); }
Example #19
Source File: DesktopAssetManager.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * {@inheritDoc} */ @Override public ShaderGenerator getShaderGenerator(EnumSet<Caps> caps) { if (shaderGenerator == null) { if(caps.contains(Caps.OpenGLES30) && caps.contains(Caps.GLSL300)){ shaderGenerator = new Glsl300ShaderGenerator(this); }else if(caps.contains(Caps.GLSL150)) { shaderGenerator = new Glsl150ShaderGenerator(this); }else{ shaderGenerator = new Glsl100ShaderGenerator(this); } } return shaderGenerator; }
Example #20
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 #21
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 #22
Source File: HDRRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void reshape(ViewPort vp, int w, int h){ if (mainSceneFB != null){ renderer.deleteFrameBuffer(mainSceneFB); } mainSceneFB = new FrameBuffer(w, h, 1); mainScene = new Texture2D(w, h, bufFormat); mainSceneFB.setDepthBuffer(Format.Depth); mainSceneFB.setColorTexture(mainScene); mainScene.setMagFilter(fbMagFilter); mainScene.setMinFilter(fbMinFilter); if (msFB != null){ renderer.deleteFrameBuffer(msFB); } tone.setTexture("Texture", mainScene); Collection<Caps> caps = renderer.getCaps(); if (numSamples > 1 && caps.contains(Caps.FrameBufferMultisample)){ msFB = new FrameBuffer(w, h, numSamples); msFB.setDepthBuffer(Format.Depth); msFB.setColorBuffer(bufFormat); vp.setOutputFrameBuffer(msFB); }else{ if (numSamples > 1) logger.warning("FBO multisampling not supported on this GPU, request ignored."); vp.setOutputFrameBuffer(mainSceneFB); } createLumShaders(); }
Example #23
Source File: TestPostFilters.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void setupSkyBox() { Texture envMap; if (renderer.getCaps().contains(Caps.FloatTexture)) { envMap = assetManager.loadTexture("Textures/Sky/St Peters/StPeters.hdr"); } else { envMap = assetManager.loadTexture("Textures/Sky/St Peters/StPeters.jpg"); } rootNode.attachChild(SkyFactory.createSky(assetManager, envMap, new Vector3f(-1, -1, -1), true)); }
Example #24
Source File: TestPostFilters.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setupSkyBox() { Texture envMap; if (renderer.getCaps().contains(Caps.FloatTexture)) { envMap = assetManager.loadTexture("Textures/Sky/St Peters/StPeters.hdr"); } else { envMap = assetManager.loadTexture("Textures/Sky/St Peters/StPeters.jpg"); } Spatial sky = SkyFactory.createSky(assetManager, envMap, new Vector3f(-1f, -1f, -1f), EnvMapType.SphereMap); rootNode.attachChild(sky); }
Example #25
Source File: TestEverything.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setupHdr(){ if (renderer.getCaps().contains(Caps.GLSL100)){ toneMapFilter = new ToneMapFilter(); toneMapFilter.setWhitePoint(new Vector3f(3f, 3f, 3f)); FilterPostProcessor fpp = new FilterPostProcessor(assetManager); fpp.addFilter(toneMapFilter); viewPort.addProcessor(fpp); // setPauseOnLostFocus(false); } }
Example #26
Source File: TechniqueDef.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * Sets the shaders that this technique definition will use. * * @param vertexShader The name of the vertex shader * @param fragmentShader The name of the fragment shader * @param shaderLanguage The shader language */ public void setShaderFile(String vertexShader, String fragmentShader, String shaderLanguage){ this.vertName = vertexShader; this.fragName = fragmentShader; this.shaderLang = shaderLanguage; Caps langCap = Caps.valueOf(shaderLanguage); requiredCaps.add(langCap); usesShaders = true; }
Example #27
Source File: TestEverything.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setupSkyBox(){ Texture envMap; if (renderer.getCaps().contains(Caps.FloatTexture)){ envMap = assetManager.loadTexture("Textures/Sky/St Peters/StPeters.hdr"); }else{ envMap = assetManager.loadTexture("Textures/Sky/St Peters/StPeters.jpg"); } rootNode.attachChild(SkyFactory.createSky(assetManager, envMap, new Vector3f(-1,-1,-1), SkyFactory.EnvMapType.SphereMap)); }
Example #28
Source File: Material.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
private void autoSelectTechnique(RenderManager rm) { if (technique == null) { // NOTE: Not really needed anymore since we have technique // selection by caps. Rename all "FixedFunc" techniques to "Default" // and remove this hack. if (!rm.getRenderer().getCaps().contains(Caps.GLSL100)) { selectTechnique("FixedFunc", rm); } else { selectTechnique("Default", rm); } } else if (technique.isNeedReload()) { technique.makeCurrent(def.getAssetManager(), paramValues); } }
Example #29
Source File: TestEverything.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void setupSkyBox(){ Texture envMap; if (renderer.getCaps().contains(Caps.FloatTexture)){ envMap = assetManager.loadTexture("Textures/Sky/St Peters/StPeters.hdr"); }else{ envMap = assetManager.loadTexture("Textures/Sky/St Peters/StPeters.jpg"); } rootNode.attachChild(SkyFactory.createSky(assetManager, envMap, new Vector3f(-1,-1,-1), true)); }
Example #30
Source File: TestEverything.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void setupBasicShadow(){ if (renderer.getCaps().contains(Caps.GLSL100)){ bsr = new BasicShadowRenderer(assetManager, 1024); bsr.setDirection(lightDir); viewPort.addProcessor(bsr); } }