break out shader material into dedicated lib file
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
a6aa34a0f7
commit
ddb1145cb8
@ -1,15 +1,10 @@
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "./lib/lights.fs"
|
||||
#include "./lib/material.fs"
|
||||
|
||||
//Shaders/FragmentShader.fs
|
||||
|
||||
struct Material {
|
||||
sampler2D diffuse;
|
||||
sampler2D specular;
|
||||
float shininess;
|
||||
};
|
||||
|
||||
in vec3 FragPos;
|
||||
in vec3 ViewFragPos;
|
||||
in vec3 Normal;
|
||||
|
||||
@ -1,17 +1,12 @@
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../lib/lights.fs"
|
||||
#include "../../lib/material.fs"
|
||||
|
||||
//celShading.fs
|
||||
|
||||
|
||||
|
||||
struct Material {
|
||||
sampler2D diffuse;
|
||||
sampler2D specular;
|
||||
float shininess;
|
||||
};
|
||||
|
||||
in vec3 FragPos;
|
||||
in vec3 Normal;
|
||||
in vec2 TexCoord;
|
||||
|
||||
@ -1,17 +1,12 @@
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../../lib/lights.fs"
|
||||
#include "../../../lib/material.fs"
|
||||
|
||||
|
||||
layout (location = 0) out vec4 accum;
|
||||
layout (location = 1) out float reveal;
|
||||
|
||||
struct Material {
|
||||
sampler2D diffuse;
|
||||
sampler2D specular;
|
||||
float shininess;
|
||||
};
|
||||
|
||||
|
||||
//inputs
|
||||
in vec3 FragPos;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../lib/lights.fs"
|
||||
#include "../../lib/material.fs"
|
||||
|
||||
//texture defines
|
||||
#define ATLAS_ELEMENT_DIM 256.0
|
||||
@ -10,12 +11,6 @@
|
||||
#define ATLAS_NORMALIZED_ELEMENT_WIDTH_FULL 0.03125 //used to properly shift from texture to texture in the atlas
|
||||
|
||||
|
||||
struct Material {
|
||||
sampler2D diffuse;
|
||||
sampler2D specular;
|
||||
float shininess;
|
||||
};
|
||||
|
||||
in vec3 FragPos;
|
||||
in vec3 ViewFragPos;
|
||||
in vec3 Normal;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../lib/lights.fs"
|
||||
#include "../../lib/material.fs"
|
||||
|
||||
//texture defines
|
||||
#define ATLAS_ELEMENT_DIM 256.0
|
||||
@ -10,12 +11,6 @@
|
||||
#define ATLAS_NORMALIZED_ELEMENT_WIDTH_FULL 0.03125 //used to properly shift from texture to texture in the atlas
|
||||
|
||||
|
||||
struct Material {
|
||||
sampler2D diffuse;
|
||||
sampler2D specular;
|
||||
float shininess;
|
||||
};
|
||||
|
||||
in vec3 FragPos;
|
||||
in vec3 ViewFragPos;
|
||||
in vec3 Normal;
|
||||
|
||||
@ -1,14 +1,10 @@
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../lib/lights.fs"
|
||||
#include "../../lib/material.fs"
|
||||
|
||||
|
||||
|
||||
struct Material {
|
||||
sampler2D diffuse;
|
||||
sampler2D specular;
|
||||
float shininess;
|
||||
};
|
||||
|
||||
in vec3 FragPos;
|
||||
in vec3 Normal;
|
||||
|
||||
@ -1,15 +1,10 @@
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../lib/lights.fs"
|
||||
#include "../../lib/material.fs"
|
||||
|
||||
//foliage.fs
|
||||
|
||||
struct Material {
|
||||
sampler2D diffuse;
|
||||
sampler2D specular;
|
||||
float shininess;
|
||||
};
|
||||
|
||||
in vec3 FragPos;
|
||||
in vec3 ViewFragPos;
|
||||
in vec3 Normal;
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
//Vertex Shader
|
||||
#version 430 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../lib/material.fs"
|
||||
|
||||
|
||||
|
||||
@ -20,12 +22,6 @@ layout (location = 1) in vec3 aNormal;
|
||||
layout (location = 4) in vec2 aTex;
|
||||
|
||||
|
||||
struct Material {
|
||||
sampler2D diffuse;
|
||||
sampler2D specular;
|
||||
float shininess;
|
||||
};
|
||||
|
||||
uniform Material material;
|
||||
|
||||
uniform sampler2D dataMap;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../lib/lights.fs"
|
||||
#include "../../lib/material.fs"
|
||||
|
||||
//foliage.fs
|
||||
|
||||
@ -8,11 +9,7 @@ layout (location = 0) out vec4 accum;
|
||||
layout (location = 1) out float reveal;
|
||||
|
||||
|
||||
struct Material {
|
||||
sampler2D diffuse;
|
||||
sampler2D specular;
|
||||
float shininess;
|
||||
};
|
||||
|
||||
|
||||
in vec3 FragPos;
|
||||
in vec3 ViewFragPos;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../lib/lights.fs"
|
||||
#include "../../lib/material.fs"
|
||||
|
||||
//texture defines
|
||||
#define ATLAS_ELEMENT_DIM 256.0
|
||||
@ -10,11 +11,7 @@
|
||||
#define ATLAS_NORMALIZED_ELEMENT_WIDTH_FULL 0.03125 //used to properly shift from texture to texture in the atlas
|
||||
|
||||
|
||||
struct Material {
|
||||
sampler2D diffuse;
|
||||
sampler2D specular;
|
||||
float shininess;
|
||||
};
|
||||
|
||||
|
||||
in vec3 FragPos;
|
||||
in vec3 ViewFragPos;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../lib/lights.fs"
|
||||
#include "../../lib/material.fs"
|
||||
|
||||
//colorshift.fs
|
||||
|
||||
@ -8,11 +9,6 @@
|
||||
#define SMALL_EPSILON 0.001
|
||||
|
||||
|
||||
struct Material {
|
||||
sampler2D diffuse;
|
||||
sampler2D specular;
|
||||
float shininess;
|
||||
};
|
||||
|
||||
in vec3 FragPos;
|
||||
in vec3 ViewFragPos;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../lib/lights.fs"
|
||||
#include "../../lib/material.fs"
|
||||
|
||||
//generic.fs
|
||||
|
||||
@ -8,11 +9,7 @@
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
struct Material {
|
||||
sampler2D diffuse;
|
||||
sampler2D specular;
|
||||
float shininess;
|
||||
};
|
||||
|
||||
|
||||
in vec3 FragPos;
|
||||
in vec3 Normal;
|
||||
|
||||
@ -1,14 +1,11 @@
|
||||
#version 450 core
|
||||
#extension GL_ARB_shading_language_include : require
|
||||
#include "../../lib/lights.fs"
|
||||
#include "../../lib/material.fs"
|
||||
|
||||
//proceduraltree.fs
|
||||
|
||||
struct Material {
|
||||
sampler2D diffuse;
|
||||
sampler2D specular;
|
||||
float shininess;
|
||||
};
|
||||
|
||||
|
||||
in vec3 FragPos;
|
||||
in vec3 ViewFragPos;
|
||||
|
||||
35
assets/Shaders/lib/material.fs
Normal file
35
assets/Shaders/lib/material.fs
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
/**
|
||||
* A material
|
||||
*/
|
||||
struct Material {
|
||||
/**
|
||||
* The diffuse sampler
|
||||
*/
|
||||
sampler2D diffuse;
|
||||
|
||||
/**
|
||||
* The diffuse sampler
|
||||
*/
|
||||
sampler2D specular;
|
||||
|
||||
/**
|
||||
* The shininess value
|
||||
*/
|
||||
float metallic;
|
||||
|
||||
/**
|
||||
* The shininess value
|
||||
*/
|
||||
float roughness;
|
||||
|
||||
/**
|
||||
* The shininess value
|
||||
*/
|
||||
float ior;
|
||||
|
||||
/**
|
||||
* The shininess value
|
||||
*/
|
||||
float alpha;
|
||||
};
|
||||
@ -1898,6 +1898,7 @@ Renderer code cleanup
|
||||
Shader uniform parsing from source code
|
||||
Visual shader uniform location caching
|
||||
Remove old uniforms from shaders and code to push uniforms
|
||||
Break out shader material into dedicated library file
|
||||
|
||||
|
||||
|
||||
|
||||
@ -80,16 +80,14 @@ public class VisualShader implements Shader {
|
||||
}
|
||||
Pattern includePattern = Pattern.compile("#include \"(.*)\"");
|
||||
Matcher matcher = includePattern.matcher(contents);
|
||||
int i = 1;
|
||||
while(matcher.find()){
|
||||
String group = matcher.group(i);
|
||||
String group = matcher.group(1);
|
||||
if(!includes.contains(group)){
|
||||
File directory = currentFile.getParentFile();
|
||||
File newFile = new File(directory.getPath() + "/" + group);
|
||||
String includeContent = VisualShader.recursivelyPreprocessFile(newFile, includes);
|
||||
contents = contents.replace("#include \"" + group + "\"", includeContent);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
//remove strings that we don't want to include
|
||||
contents = contents.replace("#extension GL_ARB_shading_language_include : require","");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user