[Ves] Transparency

Francis Moore francism at sensopia.com
Tue Jun 10 09:56:12 EDT 2014


Hi,

I am a researcher at Sensopia. In the last week, our team was able to 
rebuild the OpenGL interface of our app with VES on Android and on iOS. 
This transition greatly simplified our code and the app look better than 
ever, thanks to your great work on VES. There’s one thing that I did not 
understand: how transparency work in VES. I did not use the Kiwi class, 
because I want full control over the actor and the mapper. So here what 
I did and if you can tell me what is missing or wrong, it will help me a 
lot.

I create my own material like this, using the default Blinn Phong shaders:
vesShader::Ptr s_defaultBlinnPhongVertexShader;
vesShader::Ptr s_defaultBlinnPhongFragmentShader;
vesShaderProgram::Ptr s_defaultBlinnPhongShaderProgram;
vesMaterial::Ptr s_defaultBlinnPhongMaterial;

s_defaultBlinnPhongVertexShader = vesSharedPtr<vesShader>(new 
vesShader(vesShader::Vertex));
s_defaultBlinnPhongFragmentShader = vesSharedPtr<vesShader>(new 
vesShader(vesShader::Fragment));
s_defaultBlinnPhongShaderProgram = vesSharedPtr<vesShaderProgram>(new 
vesShaderProgram());
s_defaultBlinnPhongMaterial = vesSharedPtr<vesMaterial>(new vesMaterial());
s_defaultBlinnPhongVertexShader->setShaderSource(vesBuiltinShaders::vesBlinnPhong_vert());
s_defaultBlinnPhongFragmentShader->setShaderSource(vesBuiltinShaders::vesBlinnPhong_frag());
s_defaultBlinnPhongShaderProgram->addShader(s_defaultBlinnPhongVertexShader);
s_defaultBlinnPhongShaderProgram->addShader(s_defaultBlinnPhongFragmentShader);
s_defaultBlinnPhongShaderProgram->addUniform(s_modelViewUniform);
s_defaultBlinnPhongShaderProgram->addUniform(s_projectionUniform);
s_defaultBlinnPhongShaderProgram->addUniform(s_normalMatrixUniform);
s_defaultBlinnPhongShaderProgram->addUniform(s_lightDirectionUniform);
s_defaultBlinnPhongShaderProgram->addVertexAttribute(s_positionVertexAttribute, 
vesVertexAttributeKeys::Position);
s_defaultBlinnPhongShaderProgram->addVertexAttribute(s_normalVertexAttribute, 
vesVertexAttributeKeys::Normal);
s_defaultBlinnPhongShaderProgram->addVertexAttribute(s_colorVertexAttribute, 
vesVertexAttributeKeys::Color);
s_defaultBlinnPhongMaterial->addAttribute(s_defaultBlinnPhongShaderProgram);

Then I create my geometry without defining color on the vertex and pass 
it to a mapper. I set the alpha to 0.5 on the mapper using setColor.

vesMapper::Ptr RendererVES::s_redConeMapper;
s_redConeMapper = vesSharedPtr<vesMapper>(new vesMapper());
s_redConeMapper->setGeometryData(s_coneGeometryData);
s_redConeMapper->setColor(1.0, 0.0, 0.0, 0.5);

Finally, I add the mapper to an actor and add it to the renderer:
vesActor::Ptr coneActor = vesSharedPtr<vesActor>(vesActor::Ptr(new 
vesActor()));
coneActor->setMapper(s_redConeMapper);
coneActor->setMaterial(s_anchorMaterial);
coneActor->setTranslation(position);

kiwiViewer->renderer()->addActor(coneActor);
Where kiwiViewer is a class of type vesKiwiBaseApp::Ptr.

The result is an opaque red cone. What did I missed?

Thanks,
Francis Moore
Researcher
Sensopia



More information about the Ves mailing list