FIxing the transparent rendering on Mac

This commit is contained in:
samcake 2015-06-08 18:36:12 +02:00
parent 1bff9a17e1
commit 5e351c0328
8 changed files with 29 additions and 15 deletions

View file

@ -292,14 +292,18 @@ protected:
_lastMode(GL_TEXTURE) {}
} _transform;
// Pipeline Stage
void do_setPipeline(Batch& batch, uint32 paramOffset);
void do_setStateBlendFactor(Batch& batch, uint32 paramOffset);
// Uniform Stage
void do_setUniformBuffer(Batch& batch, uint32 paramOffset);
void do_setUniformTexture(Batch& batch, uint32 paramOffset);
struct UniformStageState {
};
// Pipeline Stage
void do_setPipeline(Batch& batch, uint32 paramOffset);
void do_setStateBlendFactor(Batch& batch, uint32 paramOffset);
// Standard update pipeline check that the current Program and current State or good to go for a
void updatePipeline();
// Force to reset all the state fields indicated by the 'toBeReset" signature

View file

@ -144,9 +144,8 @@ void GLBackend::updatePipeline() {
#if (GPU_TRANSFORM_PROFILE == GPU_CORE)
#else
// If shader program needs the inverseView we need to provide it
// YES InverseView in the shade is called View on the Batch interface
if (_pipeline._program_transformCamera_viewInverse >= 0) {
glUniformMatrix4fv(_pipeline._program_transformCamera_viewInverse, 1, false, (const GLfloat*) &_transform._view);
glUniformMatrix4fv(_pipeline._program_transformCamera_viewInverse, 1, false, (const GLfloat*) &_transform._transformCamera._viewInverse);
}
#endif
}

View file

@ -555,9 +555,9 @@ void DeferredLightingEffect::copyBack(RenderArgs* args) {
glPopMatrix();
}
void DeferredLightingEffect::setupTransparent(RenderArgs* args) {
void DeferredLightingEffect::setupTransparent(RenderArgs* args, int lightBufferUnit) {
auto globalLight = _allocatedLights[_globalLights.front()];
args->_batch->setUniformBuffer(4, globalLight->getSchemaBuffer());
args->_batch->setUniformBuffer(lightBufferUnit, globalLight->getSchemaBuffer());
}
void DeferredLightingEffect::loadLightProgram(const char* fragSource, bool limited, ProgramObject& program, LightLocations& locations) {

View file

@ -70,7 +70,7 @@ public:
void render();
void copyBack(RenderArgs* args);
void setupTransparent(RenderArgs* args);
void setupTransparent(RenderArgs* args, int lightBufferUnit);
// update global lighting
void setAmbientLightMode(int preset);

View file

@ -197,13 +197,17 @@ void Model::RenderPipelineLib::initLocations(gpu::ShaderPointer& program, Model:
#if (GPU_FEATURE_PROFILE == GPU_CORE)
locations.materialBufferUnit = program->getBuffers().findLocation("materialBuffer");
locations.lightBufferUnit = program->getBuffers().findLocation("lightBuffer");
#else
locations.materialBufferUnit = program->getUniforms().findLocation("materialBuffer");
locations.lightBufferUnit = program->getUniforms().findLocation("lightBuffer");
#endif
locations.clusterMatrices = program->getUniforms().findLocation("clusterMatrices");
locations.clusterIndices = program->getInputs().findLocation("clusterIndices");;
locations.clusterWeights = program->getInputs().findLocation("clusterWeights");;
}
@ -2251,6 +2255,10 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, bool tran
batch.setUniformTexture(locations->emissiveTextureUnit, !emissiveMap ?
textureCache->getWhiteTexture() : emissiveMap->getGPUTexture());
}
if (translucent && locations->lightBufferUnit >= 0) {
DependencyManager::get<DeferredLightingEffect>()->setupTransparent(args, locations->lightBufferUnit);
}
}
}

View file

@ -374,6 +374,7 @@ private:
int clusterMatrices;
int clusterIndices;
int clusterWeights;
int lightBufferUnit;
};
QHash<QPair<int,int>, AABox> _calculatedMeshPartBoxes; // world coordinate AABoxes for all sub mesh part boxes

View file

@ -115,7 +115,7 @@ template <> void render::jobRun(const DrawTransparentDeferred& job, const SceneC
gpu::Batch batch;
args->_batch = &batch;
DependencyManager::get<DeferredLightingEffect>()->setupTransparent(renderContext->args);
glm::mat4 projMat;

View file

@ -44,8 +44,8 @@ void main(void) {
// Everything about global lighting
<@include DeferredLighting.slh@>
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
// Everything about light
@ -78,7 +78,6 @@ vec4 evalGlobalColor(float shadowAttenuation, vec3 position, vec3 normal, vec3 d
// Need the light now
Light light = getLight();
TransformCamera cam = getTransformCamera();
// mat4 viewMat = cam._viewInverse;
vec3 fragNormal;
<$transformEyeToWorldDir(cam, normal, fragNormal)$>
vec3 fragEyeVectorView = normalize(-position);
@ -91,7 +90,10 @@ vec4 evalGlobalColor(float shadowAttenuation, vec3 position, vec3 normal, vec3 d
color += vec3(opacity * diffuse + shading.rgb) * shading.w * shadowAttenuation * getLightColor(light) * getLightIntensity(light);
//return vec4(color, opacity);
return vec4(color, opacity);
//return vec4(diffuse.rgb, opacity);
//return evalNormalColor(fragEyeDir, opacity);
}
// the diffuse texture