Graphics: Separate pipeline state from Material into a new class, MaterialPipeline
This allows much more efficient batching, along with pipeline reusage and preparation for the Vulkan API Former-commit-id: 4ed2f66567f7da6b6b6ee073e4d855b9a935000d [formerly b540f468fc700a16d5136d4dbb8632e23882fd3d] [formerly 37fff624ec65cc387130875410b6ea35c1a5bcfb [formerly ab9a88f514f46f6596499e285981fa6da588bb03]] Former-commit-id: a2e8859196c0f72b7d7ffd8764a887e6c8173743 [formerly c886cdade14769db243ff993a1741f6052a2eb2a] Former-commit-id: e1d02662fb1ac165c7e888380afee7601350060f
This commit is contained in:
@@ -132,7 +132,7 @@ void main()
|
||||
vec2 texCoord = vTexCoord;
|
||||
#endif
|
||||
|
||||
#if LIGHTING && PARALLAX_MAPPING
|
||||
#if PARALLAX_MAPPING
|
||||
float height = texture(MaterialHeightMap, texCoord).r;
|
||||
float v = height*ParallaxScale + ParallaxBias;
|
||||
|
||||
@@ -159,17 +159,16 @@ void main()
|
||||
discard;
|
||||
#endif // ALPHA_TEST
|
||||
|
||||
#if LIGHTING
|
||||
#if NORMAL_MAPPING
|
||||
#if NORMAL_MAPPING
|
||||
vec3 normal = normalize(vLightToWorld * (2.0 * vec3(texture(MaterialNormalMap, texCoord)) - 1.0));
|
||||
#else
|
||||
#else
|
||||
vec3 normal = normalize(vNormal);
|
||||
#endif // NORMAL_MAPPING
|
||||
#endif // NORMAL_MAPPING
|
||||
|
||||
vec3 specularColor = MaterialSpecular.rgb;
|
||||
#if SPECULAR_MAPPING
|
||||
#if SPECULAR_MAPPING
|
||||
specularColor *= texture(MaterialSpecularMap, texCoord).rgb;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
Texture0: Diffuse Color + Specular
|
||||
@@ -179,9 +178,6 @@ void main()
|
||||
RenderTarget0 = vec4(diffuseColor.rgb, dot(specularColor, vec3(0.3, 0.59, 0.11)));
|
||||
RenderTarget1 = vec4(EncodeNormal(normal));
|
||||
RenderTarget2 = vec4(FloatToColor(gl_FragCoord.z), (MaterialShininess == 0.0) ? 0.0 : max(log2(MaterialShininess), 0.1)/10.5); // http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf
|
||||
#else // LIGHTING
|
||||
RenderTarget0 = vec4(diffuseColor.rgb, 0.0);
|
||||
#endif
|
||||
#else // FLAG_DEFERRED
|
||||
#if ALPHA_MAPPING
|
||||
diffuseColor.a *= texture(MaterialAlphaMap, texCoord).r;
|
||||
@@ -192,16 +188,15 @@ void main()
|
||||
discard;
|
||||
#endif
|
||||
|
||||
#if LIGHTING
|
||||
vec3 lightAmbient = vec3(0.0);
|
||||
vec3 lightDiffuse = vec3(0.0);
|
||||
vec3 lightSpecular = vec3(0.0);
|
||||
|
||||
#if NORMAL_MAPPING
|
||||
#if NORMAL_MAPPING
|
||||
vec3 normal = normalize(vLightToWorld * (2.0 * vec3(texture(MaterialNormalMap, texCoord)) - 1.0));
|
||||
#else
|
||||
#else
|
||||
vec3 normal = normalize(vNormal);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (MaterialShininess > 0.0)
|
||||
{
|
||||
@@ -459,24 +454,21 @@ void main()
|
||||
}
|
||||
|
||||
lightSpecular *= MaterialSpecular.rgb;
|
||||
#if SPECULAR_MAPPING
|
||||
#if SPECULAR_MAPPING
|
||||
lightSpecular *= texture(MaterialSpecularMap, texCoord).rgb; // Utiliser l'alpha de MaterialSpecular n'aurait aucun sens
|
||||
#endif
|
||||
#endif
|
||||
|
||||
vec3 lightColor = (lightAmbient + lightDiffuse + lightSpecular);
|
||||
vec4 fragmentColor = vec4(lightColor, 1.0) * diffuseColor;
|
||||
|
||||
#if EMISSIVE_MAPPING
|
||||
#if EMISSIVE_MAPPING
|
||||
float lightIntensity = dot(lightColor, vec3(0.3, 0.59, 0.11));
|
||||
|
||||
vec3 emissionColor = MaterialDiffuse.rgb * texture(MaterialEmissiveMap, texCoord).rgb;
|
||||
RenderTarget0 = vec4(mix(fragmentColor.rgb, emissionColor, clamp(1.0 - 3.0*lightIntensity, 0.0, 1.0)), fragmentColor.a);
|
||||
#else
|
||||
RenderTarget0 = fragmentColor;
|
||||
#endif // EMISSIVE_MAPPING
|
||||
#else
|
||||
RenderTarget0 = diffuseColor;
|
||||
#endif // LIGHTING
|
||||
RenderTarget0 = fragmentColor;
|
||||
#endif // EMISSIVE_MAPPING
|
||||
#endif // FLAG_DEFERRED
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -12,6 +12,7 @@ in vec3 VertexPosition;
|
||||
in vec3 VertexNormal;
|
||||
in vec3 VertexTangent;
|
||||
in vec2 VertexTexCoord;
|
||||
in vec4 VertexUserdata0;
|
||||
|
||||
/********************Sortant********************/
|
||||
out vec4 vColor;
|
||||
@@ -27,6 +28,7 @@ uniform vec3 EyePosition;
|
||||
uniform mat4 InvViewMatrix;
|
||||
uniform mat4 LightViewProjMatrix[3];
|
||||
uniform float VertexDepth;
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ViewProjMatrix;
|
||||
uniform mat4 WorldMatrix;
|
||||
uniform mat4 WorldViewProjMatrix;
|
||||
@@ -107,21 +109,19 @@ void main()
|
||||
|
||||
vColor = color;
|
||||
|
||||
#if LIGHTING
|
||||
#if FLAG_INSTANCING
|
||||
#if FLAG_INSTANCING
|
||||
mat3 rotationMatrix = mat3(InstanceData0);
|
||||
#else
|
||||
#else
|
||||
mat3 rotationMatrix = mat3(WorldMatrix);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if COMPUTE_TBNMATRIX
|
||||
#if COMPUTE_TBNMATRIX
|
||||
vec3 binormal = cross(VertexNormal, VertexTangent);
|
||||
vLightToWorld[0] = normalize(rotationMatrix * VertexTangent);
|
||||
vLightToWorld[1] = normalize(rotationMatrix * binormal);
|
||||
vLightToWorld[2] = normalize(rotationMatrix * VertexNormal);
|
||||
#else
|
||||
#else
|
||||
vNormal = normalize(rotationMatrix * VertexNormal);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if SHADOW_MAPPING
|
||||
@@ -133,12 +133,12 @@ void main()
|
||||
vTexCoord = VertexTexCoord;
|
||||
#endif
|
||||
|
||||
#if LIGHTING && PARALLAX_MAPPING
|
||||
#if PARALLAX_MAPPING
|
||||
vViewDir = EyePosition - VertexPosition;
|
||||
vViewDir *= vLightToWorld;
|
||||
#endif
|
||||
|
||||
#if LIGHTING && !FLAG_DEFERRED
|
||||
#if !FLAG_DEFERRED
|
||||
#if FLAG_INSTANCING
|
||||
vWorldPos = vec3(InstanceData0 * vec4(VertexPosition, 1.0));
|
||||
#else
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user