Merging with master to be able connect to dev domains and it works. fixing shaders for gles compile errors and disabling material textures by default

This commit is contained in:
Sam Gateau 2018-01-13 02:00:34 -08:00
parent df0660f823
commit 57f1ba2412
5 changed files with 85 additions and 19 deletions

View file

@ -150,6 +150,10 @@ void GLBackend::resetUniformStage() {
void GLBackend::do_setUniformBuffer(const Batch& batch, size_t paramOffset) { void GLBackend::do_setUniformBuffer(const Batch& batch, size_t paramOffset) {
GLuint slot = batch._params[paramOffset + 3]._uint; GLuint slot = batch._params[paramOffset + 3]._uint;
if (slot >(GLuint)MAX_NUM_UNIFORM_BUFFERS) {
qCDebug(gpugllogging) << "GLBackend::do_setUniformBuffer: Trying to set a uniform Buffer at slot #" << slot << " which doesn't exist. MaxNumUniformBuffers = " << getMaxNumUniformBuffers();
return;
}
BufferPointer uniformBuffer = batch._buffers.get(batch._params[paramOffset + 2]._uint); BufferPointer uniformBuffer = batch._buffers.get(batch._params[paramOffset + 2]._uint);
GLintptr rangeStart = batch._params[paramOffset + 1]._uint; GLintptr rangeStart = batch._params[paramOffset + 1]._uint;
GLsizeiptr rangeSize = batch._params[paramOffset + 0]._uint; GLsizeiptr rangeSize = batch._params[paramOffset + 0]._uint;

View file

@ -96,7 +96,7 @@ protected:
float enableObscurance{ 1.0f }; float enableObscurance{ 1.0f };
float enableMaterialTexturing { 1.0f }; float enableMaterialTexturing { 0.0f };
float enableWireframe { 0.0f }; // false by default float enableWireframe { 0.0f }; // false by default
Parameters() {} Parameters() {}
@ -148,7 +148,7 @@ public:
bool enableSpecular{ true }; bool enableSpecular{ true };
bool enableAlbedo{ true }; bool enableAlbedo{ true };
bool enableMaterialTexturing { true }; bool enableMaterialTexturing { false };
bool enableAmbientLight{ true }; bool enableAmbientLight{ true };
bool enableDirectionalLight{ true }; bool enableDirectionalLight{ true };

View file

@ -39,12 +39,12 @@ mat4 dualQuatToMat4(vec4 real, vec4 dual) {
twoRealXZ - twoRealYW, twoRealXZ - twoRealYW,
0.0); 0.0);
vec4 col1 = vec4(twoRealXY - twoRealZW, vec4 col1 = vec4(twoRealXY - twoRealZW,
1 - twoRealXSq - twoRealZSq, 1.0 - twoRealXSq - twoRealZSq,
twoRealYZ + twoRealXW, twoRealYZ + twoRealXW,
0.0); 0.0);
vec4 col2 = vec4(twoRealXZ + twoRealYW, vec4 col2 = vec4(twoRealXZ + twoRealYW,
twoRealYZ - twoRealXW, twoRealYZ - twoRealXW,
1 - twoRealXSq - twoRealYSq, 1.0 - twoRealXSq - twoRealYSq,
0.0); 0.0);
vec4 col3 = vec4(2.0 * (-dual.w * real.x + dual.x * real.w - dual.y * real.z + dual.z * real.y), vec4 col3 = vec4(2.0 * (-dual.w * real.x + dual.x * real.w - dual.y * real.z + dual.z * real.y),
2.0 * (-dual.w * real.y + dual.x * real.z + dual.y * real.w - dual.z * real.x), 2.0 * (-dual.w * real.y + dual.x * real.z + dual.y * real.w - dual.z * real.x),
@ -72,7 +72,7 @@ void skinPosition(ivec4 skinClusterIndex, vec4 skinClusterWeight, vec4 inPositio
// to ensure that we rotate along the shortest arc, reverse dual quaternions with negative polarity. // to ensure that we rotate along the shortest arc, reverse dual quaternions with negative polarity.
float dqClusterWeight = clusterWeight; float dqClusterWeight = clusterWeight;
if (dot(real, polarityReference) < 0) { if (dot(real, polarityReference) < 0.0) {
dqClusterWeight = -clusterWeight; dqClusterWeight = -clusterWeight;
} }
@ -110,7 +110,7 @@ void skinPositionNormal(ivec4 skinClusterIndex, vec4 skinClusterWeight, vec4 inP
// to ensure that we rotate along the shortest arc, reverse dual quaternions with negative polarity. // to ensure that we rotate along the shortest arc, reverse dual quaternions with negative polarity.
float dqClusterWeight = clusterWeight; float dqClusterWeight = clusterWeight;
if (dot(real, polarityReference) < 0) { if (dot(real, polarityReference) < 0.0) {
dqClusterWeight = -clusterWeight; dqClusterWeight = -clusterWeight;
} }
@ -149,7 +149,7 @@ void skinPositionNormalTangent(ivec4 skinClusterIndex, vec4 skinClusterWeight, v
// to ensure that we rotate along the shortest arc, reverse dual quaternions with negative polarity. // to ensure that we rotate along the shortest arc, reverse dual quaternions with negative polarity.
float dqClusterWeight = clusterWeight; float dqClusterWeight = clusterWeight;
if (dot(real, polarityReference) < 0) { if (dot(real, polarityReference) < 0.0) {
dqClusterWeight = -clusterWeight; dqClusterWeight = -clusterWeight;
} }

View file

@ -12,10 +12,17 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
<@include ForwardBufferWrite.slh@>
<!<@include ForwardBufferWrite.slh@> !>
<@include ForwardGlobalLight.slh@>
<$declareEvalSkyboxGlobalColor()$>
<@include model/Material.slh@> <@include model/Material.slh@>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<@include MaterialTextures.slh@> <@include MaterialTextures.slh@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION)$> <$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION)$>
@ -26,6 +33,8 @@ in vec3 _normal;
in vec3 _tangent; in vec3 _tangent;
in vec3 _color; in vec3 _color;
out vec4 _fragColor;
void main(void) { void main(void) {
Material mat = getMaterial(); Material mat = getMaterial();
int matKey = getMaterialKey(mat); int matKey = getMaterialKey(mat);
@ -51,16 +60,32 @@ void main(void) {
float metallic = getMaterialMetallic(mat); float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fresnel = vec3(0.03); // Default Di-electric fresnel value
if (metallic <= 0.5) {
metallic = 0.0;
}
else {
fresnel = albedo;
metallic = 1.0;
}
vec3 fragPosition = _position.xyz;
float scattering = getMaterialScattering(mat); TransformCamera cam = getTransformCamera();
packForwardFragment( vec4 color = vec4(evalSkyboxGlobalColor(
normalize(viewNormal.xyz), cam._viewInverse,
opacity, 1.0,
1.0,
fragPosition,
viewNormal,
albedo, albedo,
roughness, fresnel,
metallic, metallic,
emissive, roughness),
occlusionTex, opacity);
scattering);
color.rgb += emissive * isEmissiveEnabled();
// _fragColor = vec4(albedo, opacity);
_fragColor = color;
} }

View file

@ -12,10 +12,17 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
<@include ForwardBufferWrite.slh@>
<!<@include ForwardBufferWrite.slh@> !>
<@include ForwardGlobalLight.slh@>
<$declareEvalSkyboxGlobalColor()$>
<@include model/Material.slh@> <@include model/Material.slh@>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<@include MaterialTextures.slh@> <@include MaterialTextures.slh@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$> <$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$>
@ -25,12 +32,13 @@ in vec2 _texCoord1;
in vec3 _normal; in vec3 _normal;
in vec3 _color; in vec3 _color;
out vec4 _fragColor;
void main(void) { void main(void) {
Material mat = getMaterial(); Material mat = getMaterial();
int matKey = getMaterialKey(mat); int matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$> <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> <! <$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$> !>
float opacity = 1.0; float opacity = 1.0;
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
@ -48,7 +56,14 @@ void main(void) {
float metallic = getMaterialMetallic(mat); float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>; <$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fresnel = vec3(0.03); // Default Di-electric fresnel value
if (metallic <= 0.5) {
metallic = 0.0;
}
else {
fresnel = albedo;
metallic = 1.0;
}/*
float scattering = getMaterialScattering(mat); float scattering = getMaterialScattering(mat);
packForwardFragment( packForwardFragment(
@ -60,4 +75,26 @@ void main(void) {
emissive, emissive,
occlusionTex, occlusionTex,
scattering); scattering);
*/
vec3 fragPosition = _position.xyz;
TransformCamera cam = getTransformCamera();
vec3 fragNormal;
<$transformEyeToWorldDir(cam, _normal, fragNormal)$>
vec4 color = vec4(evalSkyboxGlobalColor(
cam._viewInverse,
1.0,
1.0,
fragPosition,
fragNormal,
albedo,
fresnel,
metallic,
roughness),
opacity);
color.rgb += emissive * isEmissiveEnabled();
// _fragColor = vec4(albedo, opacity);
_fragColor = color;
} }