use of com.jme3.material.Technique in project jmonkeyengine by jMonkeyEngine.
the class AbstractShadowRendererVR method postFrame.
public void postFrame(FrameBuffer out) {
if (skipPostPass) {
return;
}
if (debug) {
displayShadowMap(renderManager.getRenderer());
}
getReceivers(lightReceivers);
if (lightReceivers.size() != 0) {
//setting params to recieving geometry list
setMatParams(lightReceivers);
Camera cam = viewPort.getCamera();
//some materials in the scene does not have a post shadow technique so we're using the fall back material
if (needsfallBackMaterial) {
renderManager.setForcedMaterial(postshadowMat);
}
//forcing the post shadow technique and render state
renderManager.setForcedTechnique(postTechniqueName);
//rendering the post shadow pass
viewPort.getQueue().renderShadowQueue(lightReceivers, renderManager, cam, false);
//resetting renderManager settings
renderManager.setForcedTechnique(null);
renderManager.setForcedMaterial(null);
renderManager.setCamera(cam, false);
//clearing the params in case there are some other shadow renderers
clearMatParams();
}
}
use of com.jme3.material.Technique in project jmonkeyengine by jMonkeyEngine.
the class PssmShadowRenderer method setMatParams.
private void setMatParams() {
GeometryList l = lightReceivers;
//iteration throught all the geometries of the list to gather the materials
matCache.clear();
for (int i = 0; i < l.size(); i++) {
Material mat = l.get(i).getMaterial();
//checking if the material has the post technique and adding it to the material cache
if (mat.getMaterialDef().getTechniqueDefs(postTechniqueName) != null) {
if (!matCache.contains(mat)) {
matCache.add(mat);
}
} else {
needsfallBackMaterial = true;
}
}
//iterating through the mat cache and setting the parameters
for (Material mat : matCache) {
mat.setColor("Splits", splits);
mat.setFloat("ShadowMapSize", shadowMapSize);
for (int j = 0; j < nbSplits; j++) {
mat.setMatrix4("LightViewProjectionMatrix" + j, lightViewProjectionsMatrices[j]);
}
for (int j = 0; j < nbSplits; j++) {
mat.setTexture("ShadowMap" + j, shadowMaps[j]);
}
mat.setBoolean("HardwareShadows", compareMode == CompareMode.Hardware);
mat.setInt("FilterMode", filterMode.ordinal());
mat.setFloat("PCFEdge", edgesThickness);
mat.setFloat("ShadowIntensity", shadowIntensity);
if (fadeInfo != null) {
mat.setVector2("FadeInfo", fadeInfo);
}
}
applyHWShadows = false;
applyFilterMode = false;
applyPCFEdge = false;
applyShadowIntensity = false;
applyFadeInfo = false;
//so we fall back to the forced material solution (transparent shadows won't be supported for these objects)
if (needsfallBackMaterial) {
setPostShadowParams();
}
}
use of com.jme3.material.Technique in project jmonkeyengine by jMonkeyEngine.
the class Material method preload.
/**
* 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) {
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;
}
Shader shader = technique.makeCurrent(renderManager, null, null, null, rendererCaps);
updateShaderMaterialParameters(renderer, shader, null, null);
renderManager.getRenderer().setShader(shader);
}
use of com.jme3.material.Technique in project jmonkeyengine by jMonkeyEngine.
the class TechniqueDef method setShaderFile.
/**
* 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);
}
}
}
use of com.jme3.material.Technique in project jmonkeyengine by jMonkeyEngine.
the class TechniqueDef method setShaderFile.
/**
* 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 vertLanguage The vertex shader language
* @param fragLanguage The fragment shader language
*/
public void setShaderFile(String vertexShader, String fragmentShader, String vertLanguage, String fragLanguage) {
this.shaderLanguages.put(Shader.ShaderType.Vertex, vertLanguage);
this.shaderNames.put(Shader.ShaderType.Vertex, vertexShader);
this.shaderLanguages.put(Shader.ShaderType.Fragment, fragLanguage);
this.shaderNames.put(Shader.ShaderType.Fragment, fragmentShader);
requiredCaps.clear();
Caps vertCap = Caps.valueOf(vertLanguage);
requiredCaps.add(vertCap);
Caps fragCap = Caps.valueOf(fragLanguage);
requiredCaps.add(fragCap);
weight = Math.max(vertCap.ordinal(), fragCap.ordinal());
}
Aggregations