|
|
|
@ -70,13 +70,15 @@ public abstract class ShaderGenerator { |
|
|
|
|
this.assetManager = assetManager; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void initialize(TechniqueDef techniqueDef){ |
|
|
|
|
public void initialize(TechniqueDef techniqueDef) { |
|
|
|
|
this.techniqueDef = techniqueDef; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Generate vertex and fragment shaders for the given technique |
|
|
|
|
* |
|
|
|
|
* @param definesSourceCode Defines to include alongside the shader. May be |
|
|
|
|
* null. |
|
|
|
|
* @return a Shader program |
|
|
|
|
*/ |
|
|
|
|
public Shader generateShader(String definesSourceCode) { |
|
|
|
@ -114,9 +116,9 @@ public abstract class ShaderGenerator { |
|
|
|
|
* @return the code of the generated vertex shader |
|
|
|
|
*/ |
|
|
|
|
protected String buildShader(List<ShaderNode> shaderNodes, ShaderGenerationInfo info, ShaderType type) { |
|
|
|
|
if (type == ShaderType.TessellationControl || |
|
|
|
|
type == ShaderType.TessellationEvaluation || |
|
|
|
|
type == ShaderType.Geometry) { |
|
|
|
|
if (type == ShaderType.TessellationControl |
|
|
|
|
|| type == ShaderType.TessellationEvaluation |
|
|
|
|
|| type == ShaderType.Geometry) { |
|
|
|
|
// TODO: Those are not supported.
|
|
|
|
|
// Too much code assumes that type is either Vertex or Fragment
|
|
|
|
|
return null; |
|
|
|
@ -192,8 +194,8 @@ public abstract class ShaderGenerator { |
|
|
|
|
if (loadedSource.length() > 1) { |
|
|
|
|
loadedSource = loadedSource.substring(0, loadedSource.lastIndexOf("}")); |
|
|
|
|
String[] sourceParts = loadedSource.split("\\s*void\\s*main\\s*\\(\\s*\\)\\s*\\{"); |
|
|
|
|
if(sourceParts.length<2){ |
|
|
|
|
throw new IllegalArgumentException("Syntax error in "+ shaderPath +". Cannot find 'void main(){' in \n"+ loadedSource); |
|
|
|
|
if (sourceParts.length < 2) { |
|
|
|
|
throw new IllegalArgumentException("Syntax error in " + shaderPath + ". Cannot find 'void main(){' in \n" + loadedSource); |
|
|
|
|
} |
|
|
|
|
generateDeclarativeSection(sourceDeclaration, shaderNode, sourceParts[0], info); |
|
|
|
|
generateNodeMainSection(source, shaderNode, sourceParts[1], info); |
|
|
|
|