Merge pull request #19508 from Mee-gu/feature/UpdateParticle3D

[BugFix] fix particle3D
This commit is contained in:
minggo 2019-03-13 18:01:25 +08:00 committed by GitHub
commit 63fde51dc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 15 deletions

View File

@ -715,7 +715,12 @@ LayerRadialGradient::LayerRadialGradient()
_expandLocation = pipelineDescriptor.programState->getUniformLocation("u_expand");
auto& vertexLayout = _customCommand.getPipelineDescriptor().vertexLayout;
vertexLayout.setAtrribute("a_position", 0, backend::VertexFormat::FLOAT2, 0, false);
const auto& attributeInfo = _programState->getProgram()->getActiveAttributes();
auto iter = attributeInfo.find("a_position");
if(iter != attributeInfo.end())
{
vertexLayout.setAtrribute("a_position", iter->second.location, backend::VertexFormat::FLOAT2, 0, false);
}
vertexLayout.setLayout(sizeof(_vertices[0]), backend::VertexStepMode::VERTEX);
_customCommand.createVertexBuffer(sizeof(_vertices[0]), sizeof(_vertices) / sizeof(_vertices[0]), CustomCommand::BufferUsage::STATIC);

View File

@ -206,10 +206,22 @@ bool Particle3DQuadRender::initQuadRender( const std::string& texFile )
auto &pipelineDescriptor = _meshCommand.getPipelineDescriptor();
pipelineDescriptor.programState = _programState;
auto &layout = pipelineDescriptor.vertexLayout;
layout.setAtrribute("a_position", 0, backend::VertexFormat::FLOAT3, offsetof(posuvcolor, position), false);
layout.setAtrribute("a_texCoord", 1, backend::VertexFormat::FLOAT2, offsetof(posuvcolor, uv), false);
layout.setAtrribute("a_color", 2, backend::VertexFormat::FLOAT4, offsetof(posuvcolor, color), false);
const auto& attributeInfo = _programState->getProgram()->getActiveAttributes();
auto iter = attributeInfo.find("a_position");
if(iter != attributeInfo.end())
{
layout.setAtrribute("a_position", iter->second.location, backend::VertexFormat::FLOAT3, offsetof(posuvcolor, position), false);
}
iter = attributeInfo.find("a_texCoord");
if(iter != attributeInfo.end())
{
layout.setAtrribute("a_texCoord", iter->second.location, backend::VertexFormat::FLOAT2, offsetof(posuvcolor, uv), false);
}
iter = attributeInfo.find("a_color");
if(iter != attributeInfo.end())
{
layout.setAtrribute("a_color", iter->second.location, backend::VertexFormat::FLOAT4, offsetof(posuvcolor, color), false);
}
layout.setLayout(sizeof(posuvcolor), backend::VertexStepMode::VERTEX);
_locColor = _programState->getUniformLocation("u_color");

View File

@ -664,15 +664,25 @@ void PUBillboardChain::init( const std::string &texFile )
_programState = new backend::ProgramState(CC3D_particle_vert, CC3D_particleColor_frag);
}
GLsizei stride = sizeof(VertexInfo);
auto &pipelineDescriptor = _meshCommand.getPipelineDescriptor();
pipelineDescriptor.programState = _programState;
auto &layout = pipelineDescriptor.vertexLayout;
layout.setAtrribute("a_position", 0, backend::VertexFormat::FLOAT3, offsetof(VertexInfo, position), false);
layout.setAtrribute("a_texCoord", 1, backend::VertexFormat::FLOAT2, offsetof(VertexInfo, uv), false);
layout.setAtrribute("a_color", 2, backend::VertexFormat::FLOAT4, offsetof(VertexInfo, color), false);
const auto& attributeInfo = _programState->getProgram()->getActiveAttributes();
auto iter = attributeInfo.find("a_position");
if(iter != attributeInfo.end())
{
layout.setAtrribute("a_position", iter->second.location, backend::VertexFormat::FLOAT3, offsetof(VertexInfo, position), false);
}
iter = attributeInfo.find("a_texCoord");
if(iter != attributeInfo.end())
{
layout.setAtrribute("a_texCoord", iter->second.location, backend::VertexFormat::FLOAT2, offsetof(VertexInfo, uv), false);
}
iter = attributeInfo.find("a_color");
if(iter != attributeInfo.end())
{
layout.setAtrribute("a_color", iter->second.location, backend::VertexFormat::FLOAT4, offsetof(VertexInfo, color), false);
}
layout.setLayout(sizeof(VertexInfo), backend::VertexStepMode::VERTEX);
_locColor = _programState->getUniformLocation("u_color");

View File

@ -604,10 +604,22 @@ bool PUParticle3DEntityRender::initRender( const std::string &texFile )
auto &pipelineDescriptor = _meshCommand.getPipelineDescriptor();
pipelineDescriptor.programState = _programState;
auto &layout = pipelineDescriptor.vertexLayout;
layout.setAtrribute("a_position", 0, backend::VertexFormat::FLOAT3, offsetof(VertexInfo, position), false);
layout.setAtrribute("a_texCoord", 1, backend::VertexFormat::FLOAT2, offsetof(VertexInfo, uv), false);
layout.setAtrribute("a_color", 2, backend::VertexFormat::FLOAT4, offsetof(VertexInfo, color), false);
const auto& attributeInfo = _programState->getProgram()->getActiveAttributes();
auto iter = attributeInfo.find("a_position");
if(iter != attributeInfo.end())
{
layout.setAtrribute("a_position", iter->second.location, backend::VertexFormat::FLOAT3, offsetof(VertexInfo, position), false);
}
iter = attributeInfo.find("a_texCoord");
if(iter != attributeInfo.end())
{
layout.setAtrribute("a_texCoord", iter->second.location, backend::VertexFormat::FLOAT2, offsetof(VertexInfo, uv), false);
}
iter = attributeInfo.find("a_color");
if(iter != attributeInfo.end())
{
layout.setAtrribute("a_color", iter->second.location, backend::VertexFormat::FLOAT4, offsetof(VertexInfo, color), false);
}
layout.setLayout(sizeof(VertexInfo), backend::VertexStepMode::VERTEX);
_locColor = _programState->getUniformLocation("u_color");