Merge pull request #8375 from SamGondelman/loadingFade

remove polyvox fade, fix web fade, add light fade
This commit is contained in:
Sam Gondelman 2016-08-05 11:53:15 -07:00 committed by GitHub
commit 84b7f9b186
7 changed files with 16 additions and 32 deletions

View file

@ -35,7 +35,7 @@ void RenderableLightEntityItem::render(RenderArgs* args) {
glm::vec3 color = toGlm(getXColor()); glm::vec3 color = toGlm(getXColor());
float intensity = getIntensity(); float intensity = getIntensity() * Interpolate::calculateFadeRatio(_fadeStartTime);
float falloffRadius = getFalloffRadius(); float falloffRadius = getFalloffRadius();
float exponent = getExponent(); float exponent = getExponent();
float cutoff = glm::radians(getCutoff()); float cutoff = glm::radians(getCutoff());

View file

@ -596,9 +596,6 @@ void RenderablePolyVoxEntityItem::render(RenderArgs* args) {
auto state = std::make_shared<gpu::State>(); auto state = std::make_shared<gpu::State>();
state->setCullMode(gpu::State::CULL_BACK); state->setCullMode(gpu::State::CULL_BACK);
state->setDepthTest(true, true, gpu::LESS_EQUAL); state->setDepthTest(true, true, gpu::LESS_EQUAL);
state->setBlendFunction(true,
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
_pipeline = gpu::Pipeline::create(program, state); _pipeline = gpu::Pipeline::create(program, state);
} }
@ -645,9 +642,6 @@ void RenderablePolyVoxEntityItem::render(RenderArgs* args) {
int voxelVolumeSizeLocation = _pipeline->getProgram()->getUniforms().findLocation("voxelVolumeSize"); int voxelVolumeSizeLocation = _pipeline->getProgram()->getUniforms().findLocation("voxelVolumeSize");
batch._glUniform3f(voxelVolumeSizeLocation, voxelVolumeSize.x, voxelVolumeSize.y, voxelVolumeSize.z); batch._glUniform3f(voxelVolumeSizeLocation, voxelVolumeSize.x, voxelVolumeSize.y, voxelVolumeSize.z);
int alphaLocation = _pipeline->getProgram()->getUniforms().findLocation("alpha");
batch._glUniform1f(alphaLocation, 0.5f);
batch.drawIndexed(gpu::TRIANGLES, (gpu::uint32)mesh->getNumIndices(), 0); batch.drawIndexed(gpu::TRIANGLES, (gpu::uint32)mesh->getNumIndices(), 0);
} }

View file

@ -131,7 +131,8 @@ public:
void setVolDataDirty() { withWriteLock([&] { _volDataDirty = true; }); } void setVolDataDirty() { withWriteLock([&] { _volDataDirty = true; }); }
bool isTransparent() override { return true; } // Transparent polyvox didn't seem to be working so disable for now
bool isTransparent() override { return false; }
private: private:
// The PolyVoxEntityItem class has _voxelData which contains dimensions and compressed voxel data. The dimensions // The PolyVoxEntityItem class has _voxelData which contains dimensions and compressed voxel data. The dimensions

View file

@ -214,7 +214,7 @@ void RenderableWebEntityItem::render(RenderArgs* args) {
batch._glColor4f(1.0f, 1.0f, 1.0f, fadeRatio); batch._glColor4f(1.0f, 1.0f, 1.0f, fadeRatio);
DependencyManager::get<GeometryCache>()->bindSimpleSRGBTexturedUnlitNoTexAlphaProgram(batch); DependencyManager::get<GeometryCache>()->bindSimpleSRGBTexturedUnlitNoTexAlphaProgram(batch);
DependencyManager::get<GeometryCache>()->renderQuad(batch, topLeft, bottomRight, texMin, texMax, glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)); DependencyManager::get<GeometryCache>()->renderQuad(batch, topLeft, bottomRight, texMin, texMax, glm::vec4(1.0f, 1.0f, 1.0f, fadeRatio));
} }
void RenderableWebEntityItem::setSourceUrl(const QString& value) { void RenderableWebEntityItem::setSourceUrl(const QString& value) {

View file

@ -23,7 +23,6 @@ uniform sampler2D xMap;
uniform sampler2D yMap; uniform sampler2D yMap;
uniform sampler2D zMap; uniform sampler2D zMap;
uniform vec3 voxelVolumeSize; uniform vec3 voxelVolumeSize;
uniform float alpha;
void main(void) { void main(void) {
vec3 worldNormal = cross(dFdy(_worldPosition.xyz), dFdx(_worldPosition.xyz)); vec3 worldNormal = cross(dFdy(_worldPosition.xyz), dFdx(_worldPosition.xyz));
@ -42,23 +41,13 @@ void main(void) {
vec3 yzDiffuseScaled = yzDiffuse.rgb * abs(worldNormal.x); vec3 yzDiffuseScaled = yzDiffuse.rgb * abs(worldNormal.x);
vec4 diffuse = vec4(xyDiffuseScaled + xzDiffuseScaled + yzDiffuseScaled, 1.0); vec4 diffuse = vec4(xyDiffuseScaled + xzDiffuseScaled + yzDiffuseScaled, 1.0);
const float ALPHA_THRESHOLD = 0.999; packDeferredFragment(
if (alpha < ALPHA_THRESHOLD) { _normal,
packDeferredFragmentTranslucent( 1.0,
_normal, vec3(diffuse),
alpha, DEFAULT_ROUGHNESS,
vec3(diffuse), DEFAULT_METALLIC,
DEFAULT_FRESNEL, DEFAULT_EMISSIVE,
DEFAULT_ROUGHNESS); DEFAULT_OCCLUSION,
} else { DEFAULT_SCATTERING);
packDeferredFragment(
_normal,
1.0,
vec3(diffuse),
DEFAULT_ROUGHNESS,
DEFAULT_METALLIC,
DEFAULT_EMISSIVE,
DEFAULT_OCCLUSION,
DEFAULT_SCATTERING);
}
} }

View file

@ -1785,7 +1785,7 @@ gpu::PipelinePointer GeometryCache::getSimpleSRGBTexturedUnlitNoTexAlphaPipeline
auto state = std::make_shared<gpu::State>(); auto state = std::make_shared<gpu::State>();
state->setCullMode(gpu::State::CULL_NONE); state->setCullMode(gpu::State::CULL_NONE);
state->setDepthTest(true, true, gpu::LESS_EQUAL); state->setDepthTest(true, true, gpu::LESS_EQUAL);
state->setBlendFunction(false, state->setBlendFunction(true,
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);

View file

@ -28,10 +28,10 @@ void main(void) {
texel = colorToLinearRGBA(texel); texel = colorToLinearRGBA(texel);
const float ALPHA_THRESHOLD = 0.999; const float ALPHA_THRESHOLD = 0.999;
if (_color.a * texel.a < ALPHA_THRESHOLD) { if (_color.a < ALPHA_THRESHOLD) {
packDeferredFragmentTranslucent( packDeferredFragmentTranslucent(
normalize(_normal), normalize(_normal),
_color.a * texel.a, _color.a,
_color.rgb * texel.rgb, _color.rgb * texel.rgb,
DEFAULT_FRESNEL, DEFAULT_FRESNEL,
DEFAULT_ROUGHNESS); DEFAULT_ROUGHNESS);