mirror of https://github.com/axmolengine/axmol.git
Merge pull request #12790 from pandamicro/shaderNormal
Use shader with normal while creating mesh with normals
This commit is contained in:
commit
c167e249cd
|
@ -979,7 +979,10 @@ static GLProgramState* getGLProgramStateForAttribs(MeshVertexData* meshVertexDat
|
|||
}
|
||||
else
|
||||
{
|
||||
shader = GLProgram::SHADER_3D_POSITION;
|
||||
if (hasNormal && usesLight)
|
||||
shader = GLProgram::SHADER_3D_POSITION_NORMAL;
|
||||
else
|
||||
shader = GLProgram::SHADER_3D_POSITION;
|
||||
}
|
||||
|
||||
CCASSERT(shader, "Couldn't find shader for sprite");
|
||||
|
|
|
@ -57,6 +57,7 @@ Sprite3DTests::Sprite3DTests()
|
|||
ADD_TEST_CASE(NodeAnimationTest);
|
||||
ADD_TEST_CASE(Issue9767);
|
||||
ADD_TEST_CASE(Sprite3DClippingTest);
|
||||
ADD_TEST_CASE(Sprite3DTestMeshLight);
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
@ -2616,3 +2617,35 @@ std::string Sprite3DClippingTest::subtitle() const
|
|||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
Sprite3DTestMeshLight::Sprite3DTestMeshLight()
|
||||
{
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
|
||||
auto _sprite = Sprite3D::create("Sprite3DTest/mesh_model.c3b");
|
||||
_sprite->setPosition(Vec2(0, 0));
|
||||
_sprite->setScale(0.05f);
|
||||
_sprite->setCameraMask(2);
|
||||
|
||||
PointLight * light = PointLight::create(Vec3(0, 0, 400), Color3B(255, 255, 255), 1000.0f);
|
||||
|
||||
//setup camera
|
||||
auto camera = Camera::createPerspective(40, s.width / s.height, 0.01f, 1000.f);
|
||||
camera->setCameraFlag(CameraFlag::USER1);
|
||||
camera->setPosition3D(Vec3(0.f, 30.f, 100.f));
|
||||
camera->lookAt(Vec3(0.f, 0.f, 0.f));
|
||||
addChild(camera);
|
||||
|
||||
addChild(_sprite);
|
||||
addChild(light);
|
||||
}
|
||||
|
||||
std::string Sprite3DTestMeshLight::title() const
|
||||
{
|
||||
return "3D mesh with light without texture";
|
||||
}
|
||||
|
||||
std::string Sprite3DTestMeshLight::subtitle() const
|
||||
{
|
||||
return "";
|
||||
}
|
|
@ -567,4 +567,16 @@ public:
|
|||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
||||
class Sprite3DTestMeshLight : public Sprite3DTestDemo
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(Sprite3DTestMeshLight);
|
||||
Sprite3DTestMeshLight();
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
||||
protected:
|
||||
cocos2d::Sprite3D* _sprite;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue