-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add material definition for using texture2DArray. rewrite the materia…
…l definitions and change blockskin so it just maps to offsets, this also will make it easier to atlas the textures if preferable by offset. Greedy mesher now renders partially correct textures.
- Loading branch information
Showing
24 changed files
with
676 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
#if defined(NEED_TEXCOORD1) | ||
varying vec3 texCoord1; | ||
#else | ||
varying vec2 texCoord; | ||
#endif | ||
|
||
|
||
#ifdef HAS_GLOWMAP | ||
uniform sampler2D m_GlowMap; | ||
#endif | ||
|
||
#ifdef HAS_GLOWCOLOR | ||
uniform vec4 m_GlowColor; | ||
#endif | ||
|
||
|
||
void main(){ | ||
#ifdef HAS_GLOWMAP | ||
#if defined(NEED_TEXCOORD1) | ||
gl_FragColor = texture2D(m_GlowMap, texCoord1.xy); | ||
#else | ||
gl_FragColor = texture2D(m_GlowMap, texCoord); | ||
#endif | ||
#else | ||
#ifdef HAS_GLOWCOLOR | ||
gl_FragColor = m_GlowColor; | ||
#else | ||
gl_FragColor = vec4(0.0); | ||
#endif | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#import "Common/ShaderLib/Skinning.glsllib" | ||
|
||
uniform mat4 g_WorldViewProjectionMatrix; | ||
attribute vec3 inPosition; | ||
|
||
#if defined(HAS_COLORMAP) || (defined(HAS_LIGHTMAP) && !defined(SEPARATE_TEXCOORD)) | ||
#define NEED_TEXCOORD1 | ||
#endif | ||
|
||
attribute vec3 inTexCoord; | ||
attribute vec2 inTexCoord2; | ||
attribute vec4 inColor; | ||
|
||
varying vec3 texCoord1; | ||
varying vec2 texCoord2; | ||
|
||
varying vec4 vertColor; | ||
|
||
void main(){ | ||
#ifdef NEED_TEXCOORD1 | ||
texCoord1 = inTexCoord; | ||
#endif | ||
|
||
#ifdef SEPARATE_TEXCOORD | ||
texCoord2 = inTexCoord2; | ||
#endif | ||
|
||
#ifdef HAS_VERTEXCOLOR | ||
vertColor = inColor; | ||
#endif | ||
|
||
vec4 modelSpacePos = vec4(inPosition, 1.0); | ||
#ifdef NUM_BONES | ||
Skinning_Compute(modelSpacePos); | ||
#endif | ||
gl_Position = g_WorldViewProjectionMatrix * modelSpacePos; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
#if defined(HAS_GLOWMAP) || defined(HAS_COLORMAP) || (defined(HAS_LIGHTMAP) && !defined(SEPARATE_TEXCOORD)) | ||
#define NEED_TEXCOORD1 | ||
#endif | ||
|
||
#if defined(DISCARD_ALPHA) | ||
uniform float m_AlphaDiscardThreshold; | ||
#endif | ||
|
||
uniform vec4 m_Color; | ||
uniform sampler2DArray m_ColorMap; | ||
uniform sampler2D m_LightMap; | ||
|
||
varying vec3 texCoord1; | ||
varying vec2 texCoord2; | ||
|
||
varying vec4 vertColor; | ||
|
||
void main(){ | ||
vec4 color = vec4(1.0); | ||
|
||
#ifdef HAS_COLORMAP | ||
color *= texture(m_ColorMap, texCoord1); | ||
#endif | ||
|
||
#ifdef HAS_VERTEXCOLOR | ||
color *= vertColor; | ||
#endif | ||
|
||
#ifdef HAS_COLOR | ||
color *= m_Color; | ||
#endif | ||
|
||
#ifdef HAS_LIGHTMAP | ||
#ifdef SEPARATE_TEXCOORD | ||
color.rgb *= texture(m_LightMap, texCoord2).rgb; | ||
#else | ||
color.rgb *= texture(m_LightMap, texCoord1).rgb; | ||
#endif | ||
#endif | ||
|
||
#if defined(DISCARD_ALPHA) | ||
if(color.a < m_AlphaDiscardThreshold){ | ||
discard; | ||
} | ||
#endif | ||
|
||
gl_FragColor = color; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
MaterialDef Unshaded { | ||
|
||
MaterialParameters { | ||
TextureArray ColorMap | ||
Texture2D LightMap | ||
Color Color (Color) | ||
Boolean VertexColor (UseVertexColor) | ||
Boolean SeparateTexCoord | ||
|
||
// Texture of the glowing parts of the material | ||
Texture2D GlowMap | ||
// The glow color of the object | ||
Color GlowColor | ||
|
||
// For hardware skinning | ||
Int NumberOfBones | ||
Matrix4Array BoneMatrices | ||
|
||
// Alpha threshold for fragment discarding | ||
Float AlphaDiscardThreshold (AlphaTestFallOff) | ||
|
||
//Shadows | ||
Int FilterMode | ||
Boolean HardwareShadows | ||
|
||
Texture2D ShadowMap0 | ||
Texture2D ShadowMap1 | ||
Texture2D ShadowMap2 | ||
Texture2D ShadowMap3 | ||
//pointLights | ||
Texture2D ShadowMap4 | ||
Texture2D ShadowMap5 | ||
|
||
Float ShadowIntensity | ||
Vector4 Splits | ||
Vector2 FadeInfo | ||
|
||
Matrix4 LightViewProjectionMatrix0 | ||
Matrix4 LightViewProjectionMatrix1 | ||
Matrix4 LightViewProjectionMatrix2 | ||
Matrix4 LightViewProjectionMatrix3 | ||
//pointLight | ||
Matrix4 LightViewProjectionMatrix4 | ||
Matrix4 LightViewProjectionMatrix5 | ||
Vector3 LightPos | ||
Vector3 LightDir | ||
|
||
Float PCFEdge | ||
|
||
Float ShadowMapSize | ||
} | ||
|
||
Technique { | ||
VertexShader GLSL150: MatDefs/ShaderNodes/CubeShade.vert | ||
FragmentShader GLSL150: MatDefs/ShaderNodes/CubeShade.frag | ||
|
||
WorldParameters { | ||
WorldViewProjectionMatrix | ||
} | ||
|
||
Defines { | ||
SEPARATE_TEXCOORD : SeparateTexCoord | ||
HAS_COLORMAP : ColorMap | ||
HAS_LIGHTMAP : LightMap | ||
HAS_VERTEXCOLOR : VertexColor | ||
HAS_COLOR : Color | ||
NUM_BONES : NumberOfBones | ||
DISCARD_ALPHA : AlphaDiscardThreshold | ||
} | ||
} | ||
|
||
Technique { | ||
} | ||
|
||
Technique PreNormalPass { | ||
|
||
VertexShader GLSL100 : Common/MatDefs/SSAO/normal.vert | ||
FragmentShader GLSL100 : Common/MatDefs/SSAO/normal.frag | ||
|
||
WorldParameters { | ||
WorldViewProjectionMatrix | ||
WorldViewMatrix | ||
NormalMatrix | ||
} | ||
|
||
Defines { | ||
NUM_BONES : NumberOfBones | ||
} | ||
} | ||
|
||
Technique PreShadow { | ||
|
||
VertexShader GLSL150 : MatDefs/Shadow/PreShadow.vert | ||
FragmentShader GLSL150 : MatDefs/Shadow/PreShadow.frag | ||
|
||
WorldParameters { | ||
WorldViewProjectionMatrix | ||
WorldViewMatrix | ||
} | ||
|
||
Defines { | ||
COLOR_MAP : ColorMap | ||
DISCARD_ALPHA : AlphaDiscardThreshold | ||
NUM_BONES : NumberOfBones | ||
} | ||
|
||
ForcedRenderState { | ||
FaceCull Off | ||
DepthTest On | ||
DepthWrite On | ||
PolyOffset 5 3 | ||
ColorWrite Off | ||
} | ||
|
||
} | ||
|
||
|
||
Technique PostShadow15{ | ||
VertexShader GLSL150: MatDefs/Shadow/PostShadow.vert | ||
FragmentShader GLSL150: MatDefs/Shadow/PostShadow.frag | ||
|
||
WorldParameters { | ||
WorldViewProjectionMatrix | ||
WorldMatrix | ||
} | ||
|
||
Defines { | ||
HARDWARE_SHADOWS : HardwareShadows | ||
FILTER_MODE : FilterMode | ||
PCFEDGE : PCFEdge | ||
DISCARD_ALPHA : AlphaDiscardThreshold | ||
COLOR_MAP : ColorMap | ||
SHADOWMAP_SIZE : ShadowMapSize | ||
FADE : FadeInfo | ||
PSSM : Splits | ||
POINTLIGHT : LightViewProjectionMatrix5 | ||
NUM_BONES : NumberOfBones | ||
} | ||
|
||
ForcedRenderState { | ||
Blend Modulate | ||
DepthWrite Off | ||
PolyOffset -0.1 0 | ||
} | ||
} | ||
|
||
Technique Glow { | ||
|
||
VertexShader GLSL100: MatDefs/Misc/Unshaded.vert | ||
FragmentShader GLSL100: Common/MatDefs/Light/Glow.frag | ||
|
||
WorldParameters { | ||
WorldViewProjectionMatrix | ||
} | ||
|
||
Defines { | ||
NEED_TEXCOORD1 | ||
HAS_GLOWMAP : GlowMap | ||
HAS_GLOWCOLOR : GlowColor | ||
NUM_BONES : NumberOfBones | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#import "Common/ShaderLib/Skinning.glsllib" | ||
|
||
uniform mat4 g_WorldViewProjectionMatrix; | ||
attribute vec3 inPosition; | ||
|
||
#if defined(HAS_COLORMAP) || (defined(HAS_LIGHTMAP) && !defined(SEPARATE_TEXCOORD)) | ||
#define NEED_TEXCOORD1 | ||
#endif | ||
|
||
attribute vec3 inTexCoord; | ||
attribute vec2 inTexCoord2; | ||
attribute vec4 inColor; | ||
|
||
varying vec3 texCoord1; | ||
varying vec2 texCoord2; | ||
|
||
varying vec4 vertColor; | ||
|
||
void main(){ | ||
#ifdef NEED_TEXCOORD1 | ||
texCoord1 = inTexCoord; | ||
#endif | ||
|
||
#ifdef SEPARATE_TEXCOORD | ||
texCoord2 = inTexCoord2; | ||
#endif | ||
|
||
#ifdef HAS_VERTEXCOLOR | ||
vertColor = inColor; | ||
#endif | ||
|
||
vec4 modelSpacePos = vec4(inPosition, 1.0); | ||
#ifdef NUM_BONES | ||
Skinning_Compute(modelSpacePos); | ||
#endif | ||
gl_Position = g_WorldViewProjectionMatrix * modelSpacePos; | ||
} |
Oops, something went wrong.