Instancing now works with Lighting material, and shadows are supported with instanced geometries
This commit is contained in:
parent
a11bfa5e63
commit
7356b727c3
@ -132,6 +132,8 @@ MaterialDef Phong Lighting {
|
|||||||
// For hardware skinning
|
// For hardware skinning
|
||||||
Int NumberOfBones
|
Int NumberOfBones
|
||||||
Matrix4Array BoneMatrices
|
Matrix4Array BoneMatrices
|
||||||
|
|
||||||
|
Boolean UseInstancing
|
||||||
}
|
}
|
||||||
|
|
||||||
Technique {
|
Technique {
|
||||||
@ -148,6 +150,7 @@ MaterialDef Phong Lighting {
|
|||||||
ViewMatrix
|
ViewMatrix
|
||||||
CameraPosition
|
CameraPosition
|
||||||
WorldMatrix
|
WorldMatrix
|
||||||
|
ViewProjectionMatrix
|
||||||
}
|
}
|
||||||
|
|
||||||
Defines {
|
Defines {
|
||||||
@ -177,6 +180,8 @@ MaterialDef Phong Lighting {
|
|||||||
SPHERE_MAP : SphereMap
|
SPHERE_MAP : SphereMap
|
||||||
|
|
||||||
NUM_BONES : NumberOfBones
|
NUM_BONES : NumberOfBones
|
||||||
|
|
||||||
|
INSTANCING : UseInstancing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,12 +193,15 @@ MaterialDef Phong Lighting {
|
|||||||
WorldParameters {
|
WorldParameters {
|
||||||
WorldViewProjectionMatrix
|
WorldViewProjectionMatrix
|
||||||
WorldViewMatrix
|
WorldViewMatrix
|
||||||
|
ViewProjectionMatrix
|
||||||
|
ViewMatrix
|
||||||
}
|
}
|
||||||
|
|
||||||
Defines {
|
Defines {
|
||||||
COLOR_MAP : ColorMap
|
COLOR_MAP : ColorMap
|
||||||
DISCARD_ALPHA : AlphaDiscardThreshold
|
DISCARD_ALPHA : AlphaDiscardThreshold
|
||||||
NUM_BONES : NumberOfBones
|
NUM_BONES : NumberOfBones
|
||||||
|
INSTANCING : UseInstancing
|
||||||
}
|
}
|
||||||
|
|
||||||
ForcedRenderState {
|
ForcedRenderState {
|
||||||
@ -214,6 +222,8 @@ MaterialDef Phong Lighting {
|
|||||||
WorldParameters {
|
WorldParameters {
|
||||||
WorldViewProjectionMatrix
|
WorldViewProjectionMatrix
|
||||||
WorldMatrix
|
WorldMatrix
|
||||||
|
ViewProjectionMatrix
|
||||||
|
ViewMatrix
|
||||||
}
|
}
|
||||||
|
|
||||||
Defines {
|
Defines {
|
||||||
@ -227,6 +237,7 @@ MaterialDef Phong Lighting {
|
|||||||
PSSM : Splits
|
PSSM : Splits
|
||||||
POINTLIGHT : LightViewProjectionMatrix5
|
POINTLIGHT : LightViewProjectionMatrix5
|
||||||
NUM_BONES : NumberOfBones
|
NUM_BONES : NumberOfBones
|
||||||
|
INSTANCING : UseInstancing
|
||||||
}
|
}
|
||||||
|
|
||||||
ForcedRenderState {
|
ForcedRenderState {
|
||||||
@ -243,6 +254,8 @@ MaterialDef Phong Lighting {
|
|||||||
WorldParameters {
|
WorldParameters {
|
||||||
WorldViewProjectionMatrix
|
WorldViewProjectionMatrix
|
||||||
WorldMatrix
|
WorldMatrix
|
||||||
|
ViewProjectionMatrix
|
||||||
|
ViewMatrix
|
||||||
}
|
}
|
||||||
|
|
||||||
Defines {
|
Defines {
|
||||||
@ -256,6 +269,7 @@ MaterialDef Phong Lighting {
|
|||||||
PSSM : Splits
|
PSSM : Splits
|
||||||
POINTLIGHT : LightViewProjectionMatrix5
|
POINTLIGHT : LightViewProjectionMatrix5
|
||||||
NUM_BONES : NumberOfBones
|
NUM_BONES : NumberOfBones
|
||||||
|
INSTANCING : UseInstancing
|
||||||
}
|
}
|
||||||
|
|
||||||
ForcedRenderState {
|
ForcedRenderState {
|
||||||
@ -274,11 +288,14 @@ MaterialDef Phong Lighting {
|
|||||||
WorldViewProjectionMatrix
|
WorldViewProjectionMatrix
|
||||||
WorldViewMatrix
|
WorldViewMatrix
|
||||||
NormalMatrix
|
NormalMatrix
|
||||||
|
ViewProjectionMatrix
|
||||||
|
ViewMatrix
|
||||||
}
|
}
|
||||||
|
|
||||||
Defines {
|
Defines {
|
||||||
DIFFUSEMAP_ALPHA : DiffuseMap
|
DIFFUSEMAP_ALPHA : DiffuseMap
|
||||||
NUM_BONES : NumberOfBones
|
NUM_BONES : NumberOfBones
|
||||||
|
INSTANCING : UseInstancing
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -292,12 +309,15 @@ MaterialDef Phong Lighting {
|
|||||||
WorldParameters {
|
WorldParameters {
|
||||||
WorldViewProjectionMatrix
|
WorldViewProjectionMatrix
|
||||||
WorldViewMatrix
|
WorldViewMatrix
|
||||||
NormalMatrix
|
NormalMatrix
|
||||||
|
ViewProjectionMatrix
|
||||||
|
ViewMatrix
|
||||||
}
|
}
|
||||||
|
|
||||||
Defines {
|
Defines {
|
||||||
DIFFUSEMAP_ALPHA : DiffuseMap
|
DIFFUSEMAP_ALPHA : DiffuseMap
|
||||||
NUM_BONES : NumberOfBones
|
NUM_BONES : NumberOfBones
|
||||||
|
INSTANCING : UseInstancing
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -339,6 +359,8 @@ MaterialDef Phong Lighting {
|
|||||||
|
|
||||||
WorldParameters {
|
WorldParameters {
|
||||||
WorldViewProjectionMatrix
|
WorldViewProjectionMatrix
|
||||||
|
ViewProjectionMatrix
|
||||||
|
ViewMatrix
|
||||||
}
|
}
|
||||||
|
|
||||||
Defines {
|
Defines {
|
||||||
@ -347,6 +369,7 @@ MaterialDef Phong Lighting {
|
|||||||
HAS_GLOWCOLOR : GlowColor
|
HAS_GLOWCOLOR : GlowColor
|
||||||
|
|
||||||
NUM_BONES : NumberOfBones
|
NUM_BONES : NumberOfBones
|
||||||
|
INSTANCING : UseInstancing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
|
#import "Common/ShaderLib/Instancing.glsllib"
|
||||||
#define ATTENUATION
|
#define ATTENUATION
|
||||||
//#define HQ_ATTENUATION
|
//#define HQ_ATTENUATION
|
||||||
|
|
||||||
#import "Common/ShaderLib/Skinning.glsllib"
|
#import "Common/ShaderLib/Skinning.glsllib"
|
||||||
|
|
||||||
uniform mat4 g_WorldViewProjectionMatrix;
|
/*
|
||||||
uniform mat4 g_WorldViewMatrix;
|
uniform mat4 g_WorldViewProjectionMatrix;
|
||||||
uniform mat3 g_NormalMatrix;
|
uniform mat4 g_WorldViewMatrix;
|
||||||
uniform mat4 g_ViewMatrix;
|
uniform mat3 g_NormalMatrix;
|
||||||
|
uniform mat4 g_ViewMatrix;
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
uniform vec4 m_Ambient;
|
uniform vec4 m_Ambient;
|
||||||
uniform vec4 m_Diffuse;
|
uniform vec4 m_Diffuse;
|
||||||
@ -148,14 +152,14 @@ void main(){
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gl_Position = g_WorldViewProjectionMatrix * modelSpacePos;
|
gl_Position = TransformWorldViewProjection(modelSpacePos);// g_WorldViewProjectionMatrix * modelSpacePos;
|
||||||
texCoord = inTexCoord;
|
texCoord = inTexCoord;
|
||||||
#ifdef SEPARATE_TEXCOORD
|
#ifdef SEPARATE_TEXCOORD
|
||||||
texCoord2 = inTexCoord2;
|
texCoord2 = inTexCoord2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vec3 wvPosition = (g_WorldViewMatrix * modelSpacePos).xyz;
|
vec3 wvPosition = TransformWorldView(modelSpacePos).xyz;// (g_WorldViewMatrix * modelSpacePos).xyz;
|
||||||
vec3 wvNormal = normalize(g_NormalMatrix * modelSpaceNorm);
|
vec3 wvNormal = normalize(TransformNormal(modelSpaceNorm));//normalize(g_NormalMatrix * modelSpaceNorm);
|
||||||
vec3 viewDir = normalize(-wvPosition);
|
vec3 viewDir = normalize(-wvPosition);
|
||||||
|
|
||||||
//vec4 lightColor = g_LightColor[gl_InstanceID];
|
//vec4 lightColor = g_LightColor[gl_InstanceID];
|
||||||
@ -168,7 +172,7 @@ void main(){
|
|||||||
vec4 lightColor = g_LightColor;
|
vec4 lightColor = g_LightColor;
|
||||||
|
|
||||||
#if defined(NORMALMAP) && !defined(VERTEX_LIGHTING)
|
#if defined(NORMALMAP) && !defined(VERTEX_LIGHTING)
|
||||||
vec3 wvTangent = normalize(g_NormalMatrix * modelSpaceTan);
|
vec3 wvTangent = normalize(TransformNormal(modelSpaceTan));
|
||||||
vec3 wvBinormal = cross(wvNormal, wvTangent);
|
vec3 wvBinormal = cross(wvNormal, wvTangent);
|
||||||
|
|
||||||
mat3 tbnMat = mat3(wvTangent, wvBinormal * inTangent.w,wvNormal);
|
mat3 tbnMat = mat3(wvTangent, wvBinormal * inTangent.w,wvNormal);
|
||||||
@ -187,7 +191,7 @@ void main(){
|
|||||||
lightComputeDir(wvPosition, lightColor, wvLightPos, vLightDir);
|
lightComputeDir(wvPosition, lightColor, wvLightPos, vLightDir);
|
||||||
|
|
||||||
#ifdef V_TANGENT
|
#ifdef V_TANGENT
|
||||||
vNormal = normalize(g_NormalMatrix * inTangent.xyz);
|
vNormal = normalize(TransformNormal(inTangent.xyz));
|
||||||
vNormal = -cross(cross(vLightDir.xyz, vNormal), vNormal);
|
vNormal = -cross(cross(vLightDir.xyz, vNormal), vNormal);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -87,10 +87,13 @@ MaterialDef Unshaded {
|
|||||||
WorldViewProjectionMatrix
|
WorldViewProjectionMatrix
|
||||||
WorldViewMatrix
|
WorldViewMatrix
|
||||||
NormalMatrix
|
NormalMatrix
|
||||||
|
ViewProjectionMatrix
|
||||||
|
ViewMatrix
|
||||||
}
|
}
|
||||||
|
|
||||||
Defines {
|
Defines {
|
||||||
NUM_BONES : NumberOfBones
|
NUM_BONES : NumberOfBones
|
||||||
|
INSTANCING : UseInstancing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,12 +105,15 @@ MaterialDef Unshaded {
|
|||||||
WorldParameters {
|
WorldParameters {
|
||||||
WorldViewProjectionMatrix
|
WorldViewProjectionMatrix
|
||||||
WorldViewMatrix
|
WorldViewMatrix
|
||||||
|
ViewProjectionMatrix
|
||||||
|
ViewMatrix
|
||||||
}
|
}
|
||||||
|
|
||||||
Defines {
|
Defines {
|
||||||
COLOR_MAP : ColorMap
|
COLOR_MAP : ColorMap
|
||||||
DISCARD_ALPHA : AlphaDiscardThreshold
|
DISCARD_ALPHA : AlphaDiscardThreshold
|
||||||
NUM_BONES : NumberOfBones
|
NUM_BONES : NumberOfBones
|
||||||
|
INSTANCING : UseInstancing
|
||||||
}
|
}
|
||||||
|
|
||||||
ForcedRenderState {
|
ForcedRenderState {
|
||||||
@ -128,6 +134,8 @@ MaterialDef Unshaded {
|
|||||||
WorldParameters {
|
WorldParameters {
|
||||||
WorldViewProjectionMatrix
|
WorldViewProjectionMatrix
|
||||||
WorldMatrix
|
WorldMatrix
|
||||||
|
ViewProjectionMatrix
|
||||||
|
ViewMatrix
|
||||||
}
|
}
|
||||||
|
|
||||||
Defines {
|
Defines {
|
||||||
@ -141,6 +149,7 @@ MaterialDef Unshaded {
|
|||||||
PSSM : Splits
|
PSSM : Splits
|
||||||
POINTLIGHT : LightViewProjectionMatrix5
|
POINTLIGHT : LightViewProjectionMatrix5
|
||||||
NUM_BONES : NumberOfBones
|
NUM_BONES : NumberOfBones
|
||||||
|
INSTANCING : UseInstancing
|
||||||
}
|
}
|
||||||
|
|
||||||
ForcedRenderState {
|
ForcedRenderState {
|
||||||
@ -157,6 +166,8 @@ MaterialDef Unshaded {
|
|||||||
WorldParameters {
|
WorldParameters {
|
||||||
WorldViewProjectionMatrix
|
WorldViewProjectionMatrix
|
||||||
WorldMatrix
|
WorldMatrix
|
||||||
|
ViewProjectionMatrix
|
||||||
|
ViewMatrix
|
||||||
}
|
}
|
||||||
|
|
||||||
Defines {
|
Defines {
|
||||||
@ -170,6 +181,7 @@ MaterialDef Unshaded {
|
|||||||
PSSM : Splits
|
PSSM : Splits
|
||||||
POINTLIGHT : LightViewProjectionMatrix5
|
POINTLIGHT : LightViewProjectionMatrix5
|
||||||
NUM_BONES : NumberOfBones
|
NUM_BONES : NumberOfBones
|
||||||
|
INSTANCING : UseInstancing
|
||||||
}
|
}
|
||||||
|
|
||||||
ForcedRenderState {
|
ForcedRenderState {
|
||||||
@ -186,6 +198,8 @@ MaterialDef Unshaded {
|
|||||||
|
|
||||||
WorldParameters {
|
WorldParameters {
|
||||||
WorldViewProjectionMatrix
|
WorldViewProjectionMatrix
|
||||||
|
ViewProjectionMatrix
|
||||||
|
ViewMatrix
|
||||||
}
|
}
|
||||||
|
|
||||||
Defines {
|
Defines {
|
||||||
@ -193,6 +207,7 @@ MaterialDef Unshaded {
|
|||||||
HAS_GLOWMAP : GlowMap
|
HAS_GLOWMAP : GlowMap
|
||||||
HAS_GLOWCOLOR : GlowColor
|
HAS_GLOWCOLOR : GlowColor
|
||||||
NUM_BONES : NumberOfBones
|
NUM_BONES : NumberOfBones
|
||||||
|
INSTANCING : UseInstancing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -29,6 +29,7 @@ MaterialDef Post Shadow {
|
|||||||
Float PCFEdge
|
Float PCFEdge
|
||||||
|
|
||||||
Float ShadowMapSize
|
Float ShadowMapSize
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Technique {
|
Technique {
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
|
#import "Common/ShaderLib/Instancing.glsllib"
|
||||||
#import "Common/ShaderLib/Skinning.glsllib"
|
#import "Common/ShaderLib/Skinning.glsllib"
|
||||||
uniform mat4 m_LightViewProjectionMatrix0;
|
uniform mat4 m_LightViewProjectionMatrix0;
|
||||||
uniform mat4 m_LightViewProjectionMatrix1;
|
uniform mat4 m_LightViewProjectionMatrix1;
|
||||||
uniform mat4 m_LightViewProjectionMatrix2;
|
uniform mat4 m_LightViewProjectionMatrix2;
|
||||||
uniform mat4 m_LightViewProjectionMatrix3;
|
uniform mat4 m_LightViewProjectionMatrix3;
|
||||||
|
|
||||||
uniform mat4 g_WorldViewProjectionMatrix;
|
|
||||||
uniform mat4 g_WorldMatrix;
|
|
||||||
uniform mat4 g_ViewMatrix;
|
|
||||||
uniform vec3 m_LightPos;
|
uniform vec3 m_LightPos;
|
||||||
|
|
||||||
varying vec4 projCoord0;
|
varying vec4 projCoord0;
|
||||||
@ -52,7 +50,7 @@ void main(){
|
|||||||
#ifdef NUM_BONES
|
#ifdef NUM_BONES
|
||||||
Skinning_Compute(modelSpacePos);
|
Skinning_Compute(modelSpacePos);
|
||||||
#endif
|
#endif
|
||||||
gl_Position = g_WorldViewProjectionMatrix * modelSpacePos;
|
gl_Position = TransformWorldViewProjection(modelSpacePos);
|
||||||
|
|
||||||
#ifndef POINTLIGHT
|
#ifndef POINTLIGHT
|
||||||
#ifdef PSSM
|
#ifdef PSSM
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
|
#import "Common/ShaderLib/Instancing.glsllib"
|
||||||
#import "Common/ShaderLib/Skinning.glsllib"
|
#import "Common/ShaderLib/Skinning.glsllib"
|
||||||
uniform mat4 m_LightViewProjectionMatrix0;
|
uniform mat4 m_LightViewProjectionMatrix0;
|
||||||
uniform mat4 m_LightViewProjectionMatrix1;
|
uniform mat4 m_LightViewProjectionMatrix1;
|
||||||
uniform mat4 m_LightViewProjectionMatrix2;
|
uniform mat4 m_LightViewProjectionMatrix2;
|
||||||
uniform mat4 m_LightViewProjectionMatrix3;
|
uniform mat4 m_LightViewProjectionMatrix3;
|
||||||
|
|
||||||
uniform mat4 g_WorldViewProjectionMatrix;
|
|
||||||
uniform mat4 g_WorldMatrix;
|
|
||||||
|
|
||||||
out vec4 projCoord0;
|
out vec4 projCoord0;
|
||||||
out vec4 projCoord1;
|
out vec4 projCoord1;
|
||||||
@ -51,7 +50,7 @@ void main(){
|
|||||||
#ifdef NUM_BONES
|
#ifdef NUM_BONES
|
||||||
Skinning_Compute(modelSpacePos);
|
Skinning_Compute(modelSpacePos);
|
||||||
#endif
|
#endif
|
||||||
gl_Position = g_WorldViewProjectionMatrix * modelSpacePos;
|
gl_Position = TransformWorldViewProjection(modelSpacePos);
|
||||||
|
|
||||||
#ifndef POINTLIGHT
|
#ifndef POINTLIGHT
|
||||||
#ifdef PSSM
|
#ifdef PSSM
|
||||||
@ -60,7 +59,7 @@ void main(){
|
|||||||
vec4 worldPos=vec4(0.0);
|
vec4 worldPos=vec4(0.0);
|
||||||
#endif
|
#endif
|
||||||
// get the vertex in world space
|
// get the vertex in world space
|
||||||
worldPos = g_WorldMatrix * modelSpacePos;
|
worldPos = TransformWorld(modelSpacePos);
|
||||||
|
|
||||||
#ifdef DISCARD_ALPHA
|
#ifdef DISCARD_ALPHA
|
||||||
texCoord = inTexCoord;
|
texCoord = inTexCoord;
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
|
#import "Common/ShaderLib/Instancing.glsllib"
|
||||||
#import "Common/ShaderLib/Skinning.glsllib"
|
#import "Common/ShaderLib/Skinning.glsllib"
|
||||||
attribute vec3 inPosition;
|
attribute vec3 inPosition;
|
||||||
attribute vec2 inTexCoord;
|
attribute vec2 inTexCoord;
|
||||||
|
|
||||||
uniform mat4 g_WorldViewProjectionMatrix;
|
|
||||||
uniform mat4 g_WorldViewMatrix;
|
|
||||||
|
|
||||||
varying vec2 texCoord;
|
varying vec2 texCoord;
|
||||||
|
|
||||||
void main(){
|
void main(){
|
||||||
@ -13,6 +11,6 @@ void main(){
|
|||||||
#ifdef NUM_BONES
|
#ifdef NUM_BONES
|
||||||
Skinning_Compute(modelSpacePos);
|
Skinning_Compute(modelSpacePos);
|
||||||
#endif
|
#endif
|
||||||
gl_Position = g_WorldViewProjectionMatrix * modelSpacePos;
|
gl_Position = TransformWorldViewProjection(modelSpacePos);
|
||||||
texCoord = inTexCoord;
|
texCoord = inTexCoord;
|
||||||
}
|
}
|
@ -78,6 +78,11 @@ vec3 TransformNormal(vec3 vec)
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
vec4 TransformWorld(vec4 position)
|
||||||
|
{
|
||||||
|
return g_WorldMatrix * position;
|
||||||
|
}
|
||||||
|
|
||||||
vec4 TransformWorldView(vec4 position)
|
vec4 TransformWorldView(vec4 position)
|
||||||
{
|
{
|
||||||
return g_WorldViewMatrix * position;
|
return g_WorldViewMatrix * position;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#import "Common/ShaderLib/Instancing.glsllib"
|
||||||
#import "Common/ShaderLib/Skinning.glsllib"
|
#import "Common/ShaderLib/Skinning.glsllib"
|
||||||
uniform mat4 g_WorldViewProjectionMatrix;
|
uniform mat4 g_WorldViewProjectionMatrix;
|
||||||
uniform mat3 g_NormalMatrix;
|
uniform mat3 g_NormalMatrix;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user