KRSprite objects now have their own shader, rather than sharing the "Flare" shader.
Implemented per-sprite alpha. --HG-- branch : nfb
This commit is contained in:
@@ -291,8 +291,8 @@
|
||||
E4E6F68716BA5DF700E410F8 /* debug_font.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F64B16BA5D9400E410F8 /* debug_font.vsh */; };
|
||||
E4E6F68816BA5DF700E410F8 /* dust_particle.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F64C16BA5D9400E410F8 /* dust_particle.fsh */; };
|
||||
E4E6F68916BA5DF700E410F8 /* dust_particle.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F64D16BA5D9400E410F8 /* dust_particle.vsh */; };
|
||||
E4E6F68A16BA5DF700E410F8 /* flare.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F64E16BA5D9400E410F8 /* flare.fsh */; };
|
||||
E4E6F68B16BA5DF700E410F8 /* flare.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F64F16BA5D9400E410F8 /* flare.vsh */; };
|
||||
E4E6F68A16BA5DF700E410F8 /* sprite.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F64E16BA5D9400E410F8 /* sprite.fsh */; };
|
||||
E4E6F68B16BA5DF700E410F8 /* sprite.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F64F16BA5D9400E410F8 /* sprite.vsh */; };
|
||||
E4E6F68C16BA5DF700E410F8 /* light_directional.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F65016BA5D9400E410F8 /* light_directional.fsh */; };
|
||||
E4E6F68D16BA5DF700E410F8 /* light_directional.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F65116BA5D9400E410F8 /* light_directional.vsh */; };
|
||||
E4E6F68E16BA5DF700E410F8 /* light_point_inside.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F65216BA5D9400E410F8 /* light_point_inside.fsh */; };
|
||||
@@ -323,8 +323,8 @@
|
||||
E4E6F6A716BA5E0A00E410F8 /* debug_font_osx.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61116BA5D8300E410F8 /* debug_font_osx.vsh */; };
|
||||
E4E6F6A816BA5E0A00E410F8 /* dust_particle_osx.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61216BA5D8300E410F8 /* dust_particle_osx.fsh */; };
|
||||
E4E6F6A916BA5E0A00E410F8 /* dust_particle_osx.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61316BA5D8300E410F8 /* dust_particle_osx.vsh */; };
|
||||
E4E6F6AA16BA5E0A00E410F8 /* flare_osx.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61416BA5D8300E410F8 /* flare_osx.fsh */; };
|
||||
E4E6F6AB16BA5E0A00E410F8 /* flare_osx.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61516BA5D8300E410F8 /* flare_osx.vsh */; };
|
||||
E4E6F6AA16BA5E0A00E410F8 /* sprite_osx.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61416BA5D8300E410F8 /* sprite_osx.fsh */; };
|
||||
E4E6F6AB16BA5E0A00E410F8 /* sprite_osx.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61516BA5D8300E410F8 /* sprite_osx.vsh */; };
|
||||
E4E6F6AC16BA5E0A00E410F8 /* light_directional_osx.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61616BA5D8300E410F8 /* light_directional_osx.fsh */; };
|
||||
E4E6F6AD16BA5E0A00E410F8 /* light_directional_osx.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61716BA5D8300E410F8 /* light_directional_osx.vsh */; };
|
||||
E4E6F6AE16BA5E0A00E410F8 /* light_point_inside_osx.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61816BA5D8300E410F8 /* light_point_inside_osx.fsh */; };
|
||||
@@ -428,6 +428,10 @@
|
||||
E41AE1DD16B124CA00980428 /* font.tga */ = {isa = PBXFileReference; lastKnownFileType = file; path = font.tga; sourceTree = "<group>"; };
|
||||
E41B6BA716BE436100B510EB /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; };
|
||||
E41B6BA916BE437800B510EB /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/CoreAudio.framework; sourceTree = DEVELOPER_DIR; };
|
||||
E42559AA184DD4490081BB20 /* flare.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = flare.fsh; sourceTree = "<group>"; };
|
||||
E42559AC184DD45A0081BB20 /* flare.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = flare.vsh; sourceTree = "<group>"; };
|
||||
E42559AE184DD4730081BB20 /* flare_osx.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = flare_osx.fsh; sourceTree = "<group>"; };
|
||||
E42559B0184DD48B0081BB20 /* flare_osx.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = flare_osx.vsh; sourceTree = "<group>"; };
|
||||
E428C2F11669610500A16EDF /* KRAnimationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRAnimationManager.h; sourceTree = "<group>"; };
|
||||
E428C2F41669611600A16EDF /* KRAnimationManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KRAnimationManager.cpp; sourceTree = "<group>"; };
|
||||
E428C2F71669612500A16EDF /* KRAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRAnimation.h; sourceTree = "<group>"; };
|
||||
@@ -581,8 +585,8 @@
|
||||
E4E6F61116BA5D8300E410F8 /* debug_font_osx.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = debug_font_osx.vsh; sourceTree = "<group>"; };
|
||||
E4E6F61216BA5D8300E410F8 /* dust_particle_osx.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = dust_particle_osx.fsh; sourceTree = "<group>"; };
|
||||
E4E6F61316BA5D8300E410F8 /* dust_particle_osx.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = dust_particle_osx.vsh; sourceTree = "<group>"; };
|
||||
E4E6F61416BA5D8300E410F8 /* flare_osx.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = flare_osx.fsh; sourceTree = "<group>"; };
|
||||
E4E6F61516BA5D8300E410F8 /* flare_osx.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = flare_osx.vsh; sourceTree = "<group>"; };
|
||||
E4E6F61416BA5D8300E410F8 /* sprite_osx.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = sprite_osx.fsh; sourceTree = "<group>"; };
|
||||
E4E6F61516BA5D8300E410F8 /* sprite_osx.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = sprite_osx.vsh; sourceTree = "<group>"; };
|
||||
E4E6F61616BA5D8300E410F8 /* light_directional_osx.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = light_directional_osx.fsh; sourceTree = "<group>"; };
|
||||
E4E6F61716BA5D8300E410F8 /* light_directional_osx.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = light_directional_osx.vsh; sourceTree = "<group>"; };
|
||||
E4E6F61816BA5D8300E410F8 /* light_point_inside_osx.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = light_point_inside_osx.fsh; sourceTree = "<group>"; };
|
||||
@@ -609,8 +613,8 @@
|
||||
E4E6F64B16BA5D9400E410F8 /* debug_font.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = debug_font.vsh; sourceTree = "<group>"; };
|
||||
E4E6F64C16BA5D9400E410F8 /* dust_particle.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = dust_particle.fsh; sourceTree = "<group>"; };
|
||||
E4E6F64D16BA5D9400E410F8 /* dust_particle.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = dust_particle.vsh; sourceTree = "<group>"; };
|
||||
E4E6F64E16BA5D9400E410F8 /* flare.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = flare.fsh; sourceTree = "<group>"; };
|
||||
E4E6F64F16BA5D9400E410F8 /* flare.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = flare.vsh; sourceTree = "<group>"; };
|
||||
E4E6F64E16BA5D9400E410F8 /* sprite.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = sprite.fsh; sourceTree = "<group>"; };
|
||||
E4E6F64F16BA5D9400E410F8 /* sprite.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = sprite.vsh; sourceTree = "<group>"; };
|
||||
E4E6F65016BA5D9400E410F8 /* light_directional.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = light_directional.fsh; sourceTree = "<group>"; };
|
||||
E4E6F65116BA5D9400E410F8 /* light_directional.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = light_directional.vsh; sourceTree = "<group>"; };
|
||||
E4E6F65216BA5D9400E410F8 /* light_point_inside.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = light_point_inside.fsh; sourceTree = "<group>"; };
|
||||
@@ -734,8 +738,8 @@
|
||||
E4E6F64B16BA5D9400E410F8 /* debug_font.vsh */,
|
||||
E4E6F64C16BA5D9400E410F8 /* dust_particle.fsh */,
|
||||
E4E6F64D16BA5D9400E410F8 /* dust_particle.vsh */,
|
||||
E4E6F64E16BA5D9400E410F8 /* flare.fsh */,
|
||||
E4E6F64F16BA5D9400E410F8 /* flare.vsh */,
|
||||
E4E6F64E16BA5D9400E410F8 /* sprite.fsh */,
|
||||
E4E6F64F16BA5D9400E410F8 /* sprite.vsh */,
|
||||
E4E6F65016BA5D9400E410F8 /* light_directional.fsh */,
|
||||
E4E6F65116BA5D9400E410F8 /* light_directional.vsh */,
|
||||
E4E6F65216BA5D9400E410F8 /* light_point_inside.fsh */,
|
||||
@@ -759,6 +763,8 @@
|
||||
E4E6F66416BA5D9400E410F8 /* volumetric_fog_downsampled.vsh */,
|
||||
E4E6F66516BA5D9400E410F8 /* volumetric_fog.fsh */,
|
||||
E4E6F66616BA5D9400E410F8 /* volumetric_fog.vsh */,
|
||||
E42559AA184DD4490081BB20 /* flare.fsh */,
|
||||
E42559AC184DD45A0081BB20 /* flare.vsh */,
|
||||
);
|
||||
path = Shaders;
|
||||
sourceTree = "<group>";
|
||||
@@ -1153,8 +1159,8 @@
|
||||
E4E6F61116BA5D8300E410F8 /* debug_font_osx.vsh */,
|
||||
E4E6F61216BA5D8300E410F8 /* dust_particle_osx.fsh */,
|
||||
E4E6F61316BA5D8300E410F8 /* dust_particle_osx.vsh */,
|
||||
E4E6F61416BA5D8300E410F8 /* flare_osx.fsh */,
|
||||
E4E6F61516BA5D8300E410F8 /* flare_osx.vsh */,
|
||||
E4E6F61416BA5D8300E410F8 /* sprite_osx.fsh */,
|
||||
E4E6F61516BA5D8300E410F8 /* sprite_osx.vsh */,
|
||||
E4E6F61616BA5D8300E410F8 /* light_directional_osx.fsh */,
|
||||
E4E6F61716BA5D8300E410F8 /* light_directional_osx.vsh */,
|
||||
E4E6F61816BA5D8300E410F8 /* light_point_inside_osx.fsh */,
|
||||
@@ -1176,6 +1182,8 @@
|
||||
E4E6F62816BA5D8300E410F8 /* volumetric_fog_downsampled_osx.vsh */,
|
||||
E4E6F62916BA5D8300E410F8 /* volumetric_fog_osx.fsh */,
|
||||
E4E6F62A16BA5D8300E410F8 /* volumetric_fog_osx.vsh */,
|
||||
E42559AE184DD4730081BB20 /* flare_osx.fsh */,
|
||||
E42559B0184DD48B0081BB20 /* flare_osx.vsh */,
|
||||
);
|
||||
path = Shaders;
|
||||
sourceTree = "<group>";
|
||||
@@ -1511,8 +1519,8 @@
|
||||
E4E6F68716BA5DF700E410F8 /* debug_font.vsh in Resources */,
|
||||
E4E6F68816BA5DF700E410F8 /* dust_particle.fsh in Resources */,
|
||||
E4E6F68916BA5DF700E410F8 /* dust_particle.vsh in Resources */,
|
||||
E4E6F68A16BA5DF700E410F8 /* flare.fsh in Resources */,
|
||||
E4E6F68B16BA5DF700E410F8 /* flare.vsh in Resources */,
|
||||
E4E6F68A16BA5DF700E410F8 /* sprite.fsh in Resources */,
|
||||
E4E6F68B16BA5DF700E410F8 /* sprite.vsh in Resources */,
|
||||
E4E6F68C16BA5DF700E410F8 /* light_directional.fsh in Resources */,
|
||||
E4E6F68D16BA5DF700E410F8 /* light_directional.vsh in Resources */,
|
||||
E4E6F68E16BA5DF700E410F8 /* light_point_inside.fsh in Resources */,
|
||||
@@ -1551,8 +1559,8 @@
|
||||
E4E6F6A716BA5E0A00E410F8 /* debug_font_osx.vsh in Resources */,
|
||||
E4E6F6A816BA5E0A00E410F8 /* dust_particle_osx.fsh in Resources */,
|
||||
E4E6F6A916BA5E0A00E410F8 /* dust_particle_osx.vsh in Resources */,
|
||||
E4E6F6AA16BA5E0A00E410F8 /* flare_osx.fsh in Resources */,
|
||||
E4E6F6AB16BA5E0A00E410F8 /* flare_osx.vsh in Resources */,
|
||||
E4E6F6AA16BA5E0A00E410F8 /* sprite_osx.fsh in Resources */,
|
||||
E4E6F6AB16BA5E0A00E410F8 /* sprite_osx.vsh in Resources */,
|
||||
E4E6F6AC16BA5E0A00E410F8 /* light_directional_osx.fsh in Resources */,
|
||||
E4E6F6AD16BA5E0A00E410F8 /* light_directional_osx.vsh in Resources */,
|
||||
E4E6F6AE16BA5E0A00E410F8 /* light_point_inside_osx.fsh in Resources */,
|
||||
|
||||
@@ -333,6 +333,7 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
|
||||
// Render light flare on transparency pass
|
||||
KRShader *pShader = getContext().getShaderManager()->getShader("flare", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
||||
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass)) {
|
||||
pShader->setUniform(KRShader::KRENGINE_UNIFORM_MATERIAL_ALPHA, 1.0f);
|
||||
pShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, m_flareSize);
|
||||
m_pContext->getTextureManager()->selectTexture(0, m_pFlareTexture);
|
||||
m_pContext->getModelManager()->bindVBO(getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_VERTICES, getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_INDEXES, getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
||||
|
||||
@@ -36,21 +36,15 @@ KRMeshQuad::KRMeshQuad(KRContext &context) : KRMesh(context, "__quad")
|
||||
{
|
||||
KRMesh::mesh_info mi;
|
||||
|
||||
mi.vertices.push_back(KRVector3(-1.0f, -1.0f, 0.0f));
|
||||
mi.vertices.push_back(KRVector3(1.0f, -1.0f, 0.0f));
|
||||
mi.vertices.push_back(KRVector3(-1.0f, 1.0f, 0.0f));
|
||||
mi.vertices.push_back(KRVector3(1.0f, 1.0f, 0.0f));
|
||||
|
||||
mi.vertices.push_back(KRVector3(1.0, 1.0, 1.0));
|
||||
mi.vertices.push_back(KRVector3(-1.0, 1.0, 1.0));
|
||||
mi.vertices.push_back(KRVector3(1.0,-1.0, 1.0));
|
||||
mi.vertices.push_back(KRVector3(-1.0,-1.0, 1.0));
|
||||
mi.vertices.push_back(KRVector3(-1.0,-1.0,-1.0));
|
||||
mi.vertices.push_back(KRVector3(-1.0, 1.0, 1.0));
|
||||
mi.vertices.push_back(KRVector3(-1.0, 1.0,-1.0));
|
||||
mi.vertices.push_back(KRVector3(1.0, 1.0, 1.0));
|
||||
mi.vertices.push_back(KRVector3(1.0, 1.0,-1.0));
|
||||
mi.vertices.push_back(KRVector3(1.0,-1.0, 1.0));
|
||||
mi.vertices.push_back(KRVector3(1.0,-1.0,-1.0));
|
||||
mi.vertices.push_back(KRVector3(-1.0,-1.0,-1.0));
|
||||
mi.vertices.push_back(KRVector3(1.0, 1.0,-1.0));
|
||||
mi.vertices.push_back(KRVector3(-1.0, 1.0,-1.0));
|
||||
mi.uva.push_back(KRVector2(0.0f, 0.0f));
|
||||
mi.uva.push_back(KRVector2(1.0f, 0.0f));
|
||||
mi.uva.push_back(KRVector2(0.0f, 1.0f));
|
||||
mi.uva.push_back(KRVector2(1.0f, 1.0f));
|
||||
|
||||
|
||||
mi.submesh_starts.push_back(0);
|
||||
|
||||
@@ -920,4 +920,9 @@ void KRNode::addBehavior(KRBehavior *behavior)
|
||||
m_behaviors.insert(behavior);
|
||||
behavior->__setNode(this);
|
||||
getScene().notify_sceneGraphModify(this);
|
||||
}
|
||||
}
|
||||
|
||||
std::set<KRBehavior *> &KRNode::getBehaviors()
|
||||
{
|
||||
return m_behaviors;
|
||||
}
|
||||
|
||||
@@ -227,6 +227,17 @@ private:
|
||||
|
||||
public:
|
||||
void addBehavior(KRBehavior *behavior);
|
||||
std::set<KRBehavior *> &getBehaviors();
|
||||
template <class T> T *getBehavior()
|
||||
{
|
||||
for(std::set<KRBehavior *>::iterator itr=m_behaviors.begin(); itr != m_behaviors.end(); itr++) {
|
||||
T *behavior = dynamic_cast<T *>(*itr);
|
||||
if(behavior) {
|
||||
return behavior;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
void removeFromOctreeNodes();
|
||||
void addToOctreeNode(KROctreeNode *octree_node);
|
||||
void childDeleted(KRNode *child_node);
|
||||
|
||||
@@ -28,7 +28,8 @@ KRSprite::KRSprite(KRScene &scene, std::string name) : KRNode(scene, name)
|
||||
{
|
||||
m_spriteTexture = "";
|
||||
m_pSpriteTexture = NULL;
|
||||
m_spriteSize = 0.0;
|
||||
m_spriteSize = 0.0f;
|
||||
m_spriteAlpha = 1.0f;
|
||||
}
|
||||
|
||||
KRSprite::~KRSprite()
|
||||
@@ -44,6 +45,7 @@ tinyxml2::XMLElement *KRSprite::saveXML( tinyxml2::XMLNode *parent)
|
||||
tinyxml2::XMLElement *e = KRNode::saveXML(parent);
|
||||
e->SetAttribute("sprite_size", m_spriteSize);
|
||||
e->SetAttribute("sprite_texture", m_spriteTexture.c_str());
|
||||
e->SetAttribute("sprite_alpha", m_spriteAlpha);
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -51,7 +53,10 @@ void KRSprite::loadXML(tinyxml2::XMLElement *e) {
|
||||
KRNode::loadXML(e);
|
||||
|
||||
if(e->QueryFloatAttribute("sprite_size", &m_spriteSize) != tinyxml2::XML_SUCCESS) {
|
||||
m_spriteSize = 0.0;
|
||||
m_spriteSize = 0.0f;
|
||||
}
|
||||
if(e->QueryFloatAttribute("sprite_alpha", &m_spriteAlpha) != tinyxml2::XML_SUCCESS) {
|
||||
m_spriteAlpha = 1.0f;
|
||||
}
|
||||
|
||||
const char *szSpriteTexture = e->Attribute("sprite_texture");
|
||||
@@ -73,6 +78,16 @@ void KRSprite::setSpriteSize(float sprite_size) {
|
||||
m_spriteSize = sprite_size;
|
||||
}
|
||||
|
||||
void KRSprite::setSpriteAlpha(float alpha)
|
||||
{
|
||||
m_spriteAlpha = alpha;
|
||||
}
|
||||
|
||||
float KRSprite::getSpriteAlpha() const
|
||||
{
|
||||
return m_spriteAlpha;
|
||||
}
|
||||
|
||||
KRAABB KRSprite::getBounds() {
|
||||
return KRAABB(KRVector3(-m_spriteSize), KRVector3(m_spriteSize), getModelMatrix());
|
||||
}
|
||||
@@ -84,7 +99,7 @@ void KRSprite::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_ligh
|
||||
|
||||
|
||||
if(renderPass == KRNode::RENDER_PASS_ADDITIVE_PARTICLES) {
|
||||
if(m_spriteTexture.size() && m_spriteSize > 0.0f) {
|
||||
if(m_spriteTexture.size() && m_spriteSize > 0.0f && m_spriteAlpha > 0.0f) {
|
||||
|
||||
|
||||
if(!m_pSpriteTexture && m_spriteTexture.size()) {
|
||||
@@ -109,8 +124,9 @@ void KRSprite::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_ligh
|
||||
GLDEBUG(glDepthRangef(0.0, 1.0));
|
||||
|
||||
// Render light sprite on transparency pass
|
||||
KRShader *pShader = getContext().getShaderManager()->getShader("flare", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
||||
KRShader *pShader = getContext().getShaderManager()->getShader("sprite", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
||||
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass)) {
|
||||
pShader->setUniform(KRShader::KRENGINE_UNIFORM_MATERIAL_ALPHA, m_spriteAlpha);
|
||||
pShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, m_spriteSize);
|
||||
m_pContext->getTextureManager()->selectTexture(0, m_pSpriteTexture);
|
||||
m_pContext->getModelManager()->bindVBO(getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_VERTICES, getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_INDEXES, getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
||||
|
||||
@@ -24,6 +24,8 @@ public:
|
||||
|
||||
void setSpriteTexture(std::string sprite_texture);
|
||||
void setSpriteSize(float sprite_size);
|
||||
void setSpriteAlpha(float alpha);
|
||||
float getSpriteAlpha() const;
|
||||
|
||||
virtual void render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
||||
|
||||
@@ -34,6 +36,7 @@ protected:
|
||||
std::string m_spriteTexture;
|
||||
KRTexture *m_pSpriteTexture;
|
||||
float m_spriteSize;
|
||||
float m_spriteAlpha;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
@@ -23,7 +23,7 @@
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
@@ -31,7 +31,8 @@
|
||||
|
||||
varying mediump vec2 texCoord;
|
||||
uniform sampler2D diffuseTexture;
|
||||
uniform lowp float material_alpha;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vec4(vec3(texture2D(diffuseTexture, texCoord)), 1.0);
|
||||
gl_FragColor = vec4(vec3(texture2D(diffuseTexture, texCoord)), 1.0) * material_alpha;
|
||||
}
|
||||
@@ -3,17 +3,17 @@
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
@@ -23,7 +23,7 @@
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
|
||||
38
KREngine/kraken_standard_assets_ios/Shaders/sprite.fsh
Normal file
38
KREngine/kraken_standard_assets_ios/Shaders/sprite.fsh
Normal file
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// sprite.fsh
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
varying mediump vec2 texCoord;
|
||||
uniform sampler2D diffuseTexture;
|
||||
uniform lowp float material_alpha;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vec4(vec3(texture2D(diffuseTexture, texCoord)), 1.0) * material_alpha;
|
||||
}
|
||||
42
KREngine/kraken_standard_assets_ios/Shaders/sprite.vsh
Normal file
42
KREngine/kraken_standard_assets_ios/Shaders/sprite.vsh
Normal file
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// sprite.vsh
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
attribute mediump vec2 vertex_uv;
|
||||
uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices
|
||||
uniform mediump vec4 viewport;
|
||||
uniform mediump float flare_size;
|
||||
|
||||
varying mediump vec2 texCoord;
|
||||
|
||||
void main() {
|
||||
texCoord = vertex_uv;
|
||||
gl_Position = mvp_matrix * vec4(0.0, 0.0, 0.0, 1.0) + vec4(vertex_uv.x * viewport.w / viewport.z * 2.0 - 1.0, vertex_uv.y * 2.0 - 1.0, 0.0, 0.0) * flare_size;
|
||||
}
|
||||
@@ -3,17 +3,17 @@
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
@@ -23,7 +23,7 @@
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
@@ -31,7 +31,8 @@
|
||||
|
||||
varying mediump vec2 texCoord;
|
||||
uniform sampler2D diffuseTexture;
|
||||
uniform lowp float material_alpha;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vec4(vec3(texture2D(diffuseTexture, texCoord)), 1.0);
|
||||
gl_FragColor = vec4(vec3(texture2D(diffuseTexture, texCoord)), 1.0) * material_alpha;
|
||||
}
|
||||
@@ -3,17 +3,17 @@
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
@@ -23,7 +23,7 @@
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
|
||||
38
KREngine/kraken_standard_assets_osx/Shaders/sprite_osx.fsh
Normal file
38
KREngine/kraken_standard_assets_osx/Shaders/sprite_osx.fsh
Normal file
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// sprite.fsh
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
varying mediump vec2 texCoord;
|
||||
uniform sampler2D diffuseTexture;
|
||||
uniform lowp float material_alpha;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vec4(vec3(texture2D(diffuseTexture, texCoord)), 1.0) * material_alpha;
|
||||
}
|
||||
42
KREngine/kraken_standard_assets_osx/Shaders/sprite_osx.vsh
Normal file
42
KREngine/kraken_standard_assets_osx/Shaders/sprite_osx.vsh
Normal file
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// sprite.vsh
|
||||
// KREngine
|
||||
//
|
||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||
// provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// The views and conclusions contained in the software and documentation are those of the
|
||||
// authors and should not be interpreted as representing official policies, either expressed
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
attribute mediump vec2 vertex_uv;
|
||||
uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices
|
||||
uniform mediump vec4 viewport;
|
||||
uniform mediump float flare_size;
|
||||
|
||||
varying mediump vec2 texCoord;
|
||||
|
||||
void main() {
|
||||
texCoord = vertex_uv;
|
||||
gl_Position = mvp_matrix * vec4(0.0, 0.0, 0.0, 1.0) + vec4(vertex_uv.x * viewport.w / viewport.z * 2.0 - 1.0, vertex_uv.y * 2.0 - 1.0, 0.0, 0.0) * flare_size;
|
||||
}
|
||||
Reference in New Issue
Block a user