mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
transparent textures and setting up 9-patch system for texture scaling
This commit is contained in:
parent
99856df112
commit
b452566d75
2 changed files with 47 additions and 11 deletions
|
@ -68,7 +68,7 @@ void RenderablePolyLineEntityItem::createPipeline() {
|
|||
|
||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||
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::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
|
||||
_pipeline = gpu::PipelinePointer(gpu::Pipeline::create(program, state));
|
||||
|
@ -79,14 +79,20 @@ void RenderablePolyLineEntityItem::updateGeometry() {
|
|||
_verticesBuffer.reset(new gpu::Buffer());
|
||||
int vertexIndex = 0;
|
||||
vec2 uv;
|
||||
float zero = 0.01; //For some reason actual 0.0 gives color that's not part of texture...
|
||||
//Actually it's specifying exact border between two colors in texture...
|
||||
int numTailStrips = 5;
|
||||
for (int i = 0; i < _normals.size(); i++) {
|
||||
uv = vec2(0.1, 0.9);
|
||||
uv = vec2(0.26, zero);
|
||||
|
||||
|
||||
|
||||
//tail
|
||||
if(i < numTailStrips) {
|
||||
uv = vec2(0.9, 0.01);
|
||||
uv = vec2(0.76, zero);
|
||||
}
|
||||
|
||||
//head
|
||||
if( i > _normals.size() - numTailStrips ) {
|
||||
uv = vec2(zero, zero);
|
||||
}
|
||||
|
||||
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_vertices.at(vertexIndex));
|
||||
|
@ -94,10 +100,13 @@ void RenderablePolyLineEntityItem::updateGeometry() {
|
|||
// _verticesBuffer->append(sizeof(int), (gpu::Byte*)&_color);
|
||||
_verticesBuffer->append(sizeof(glm::vec2), (gpu::Byte*)&uv);
|
||||
vertexIndex++;
|
||||
uv = vec2(0.1, 0.2);
|
||||
uv = vec2(0.26, zero);
|
||||
|
||||
if(i < numTailStrips) {
|
||||
uv = vec2(0.9, 0.9);
|
||||
if (i < numTailStrips) {
|
||||
uv = vec2(0.76, zero);
|
||||
}
|
||||
if (i > _normals.size() -numTailStrips) {
|
||||
uv = vec2(zero, zero);
|
||||
}
|
||||
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_vertices.at(vertexIndex));
|
||||
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_normals.at(i));
|
||||
|
@ -113,6 +122,33 @@ void RenderablePolyLineEntityItem::updateGeometry() {
|
|||
|
||||
}
|
||||
|
||||
namespace render {
|
||||
template <> const ItemKey payloadGetKey(const RenderableEntityItemProxy::Pointer& payload) {
|
||||
if (payload && payload->entity) {
|
||||
if (payload->entity->getType() == EntityTypes::Light) {
|
||||
return ItemKey::Builder::light();
|
||||
}
|
||||
}
|
||||
return ItemKey::Builder::opaqueShape();
|
||||
}
|
||||
|
||||
template <> const Item::Bound payloadGetBound(const RenderableEntityItemProxy::Pointer& payload) {
|
||||
if (payload && payload->entity) {
|
||||
return payload->entity->getAABox();
|
||||
}
|
||||
return render::Item::Bound();
|
||||
}
|
||||
template <> void payloadRender(const RenderableEntityItemProxy::Pointer& payload, RenderArgs* args) {
|
||||
if (args) {
|
||||
if (payload && payload->entity && payload->entity->getVisible()) {
|
||||
payload->entity->render(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RenderablePolyLineEntityItem::render(RenderArgs* args) {
|
||||
QWriteLocker lock(&_quadReadWriteLock);
|
||||
if (_points.size() < 2 || _vertices.size() != _normals.size() * 2) {
|
||||
|
|
|
@ -36,11 +36,11 @@ void main(void) {
|
|||
vec4 texel = texture2D(originalTexture, varTexcoord);
|
||||
int frontCondition = 1 -int(gl_FrontFacing) * 2;
|
||||
// vec3 color = gl_Color.rgb;
|
||||
packDeferredFragment(
|
||||
//vec3 normal, float alpha, vec3 diffuse, vec3 specular, float shininess
|
||||
packDeferredFragmentTranslucent(
|
||||
newNormal * frontCondition,
|
||||
glowIntensity,
|
||||
texel.a,
|
||||
texel.rgb,
|
||||
//vec3(varTexcoord, 0.0),
|
||||
vec3(0.01, 0.01, 0.01),
|
||||
10.0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue