diff --git a/KREngine/KREngine.xcodeproj/project.pbxproj b/KREngine/KREngine.xcodeproj/project.pbxproj index 9c77caf..fb0b2f2 100644 --- a/KREngine/KREngine.xcodeproj/project.pbxproj +++ b/KREngine/KREngine.xcodeproj/project.pbxproj @@ -23,6 +23,14 @@ E42CB1ED158446940066E0D8 /* KRQuaternion.h in Headers */ = {isa = PBXBuildFile; fileRef = E42CB1EB158446940066E0D8 /* KRQuaternion.h */; settings = {ATTRIBUTES = (Public, ); }; }; E42CB1F0158446AB0066E0D8 /* KRQuaternion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E42CB1EF158446AB0066E0D8 /* KRQuaternion.cpp */; }; E42CB1F1158446AB0066E0D8 /* KRQuaternion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E42CB1EF158446AB0066E0D8 /* KRQuaternion.cpp */; }; + E4324BA416444C0D0043185B /* KRParticleSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = E4324BA316444C0D0043185B /* KRParticleSystem.h */; }; + E4324BA516444C0D0043185B /* KRParticleSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = E4324BA316444C0D0043185B /* KRParticleSystem.h */; }; + E4324BA816444C230043185B /* KRParticleSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4324BA716444C230043185B /* KRParticleSystem.cpp */; }; + E4324BAB16444DEF0043185B /* KRParticleSystemBrownian.h in Headers */ = {isa = PBXBuildFile; fileRef = E4324BAA16444DEF0043185B /* KRParticleSystemBrownian.h */; }; + E4324BAC16444DEF0043185B /* KRParticleSystemBrownian.h in Headers */ = {isa = PBXBuildFile; fileRef = E4324BAA16444DEF0043185B /* KRParticleSystemBrownian.h */; }; + E4324BAE16444E120043185B /* KRParticleSystemBrownian.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4324BAD16444E120043185B /* KRParticleSystemBrownian.cpp */; }; + E4324BAF16444E120043185B /* KRParticleSystemBrownian.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4324BAD16444E120043185B /* KRParticleSystemBrownian.cpp */; }; + E4324BB0164458930043185B /* KRParticleSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4324BA716444C230043185B /* KRParticleSystem.cpp */; }; E43B0AD615DDCA0F00A5CB9F /* KRContextObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */; }; E43B0AD715DDCA0F00A5CB9F /* KRContextObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */; }; E43B0AD815DDCA0F00A5CB9F /* KRContextObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E43B0AD515DDCA0D00A5CB9F /* KRContextObject.h */; }; @@ -35,6 +43,10 @@ E45AC0401641DE5D00DC3C3B /* debug_font.vsh in Sources */ = {isa = PBXBuildFile; fileRef = E45AC03E1641DE5D00DC3C3B /* debug_font.vsh */; }; E45AC0421641DE6D00DC3C3B /* debug_font.fsh in Sources */ = {isa = PBXBuildFile; fileRef = E45AC0411641DE6D00DC3C3B /* debug_font.fsh */; }; E45AC0431641DE6D00DC3C3B /* debug_font.fsh in Sources */ = {isa = PBXBuildFile; fileRef = E45AC0411641DE6D00DC3C3B /* debug_font.fsh */; }; + E45AC0471643451300DC3C3B /* particle.fsh in Sources */ = {isa = PBXBuildFile; fileRef = E45AC0461643451200DC3C3B /* particle.fsh */; }; + E45AC0481643451300DC3C3B /* particle.fsh in Sources */ = {isa = PBXBuildFile; fileRef = E45AC0461643451200DC3C3B /* particle.fsh */; }; + E45AC04A1643452100DC3C3B /* particle.vsh in Sources */ = {isa = PBXBuildFile; fileRef = E45AC0491643452000DC3C3B /* particle.vsh */; }; + E45AC04B1643452100DC3C3B /* particle.vsh in Sources */ = {isa = PBXBuildFile; fileRef = E45AC0491643452000DC3C3B /* particle.vsh */; }; E461A152152E54B500F2044A /* KRLight.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A151152E54B500F2044A /* KRLight.h */; }; E461A153152E54B500F2044A /* KRLight.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A151152E54B500F2044A /* KRLight.h */; settings = {ATTRIBUTES = (Public, ); }; }; E461A156152E54F800F2044A /* KRLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461A155152E54F700F2044A /* KRLight.cpp */; }; @@ -221,6 +233,10 @@ E42CB1EF158446AB0066E0D8 /* KRQuaternion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRQuaternion.cpp; path = Classes/KRQuaternion.cpp; sourceTree = ""; }; E430D08015F8882F0010558D /* occlusion_test.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = occlusion_test.fsh; path = Shaders/occlusion_test.fsh; sourceTree = ""; }; E430D08815F88AD10010558D /* occlusion_test.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = occlusion_test.vsh; path = Shaders/occlusion_test.vsh; sourceTree = ""; }; + E4324BA316444C0D0043185B /* KRParticleSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRParticleSystem.h; path = Classes/KRParticleSystem.h; sourceTree = ""; }; + E4324BA716444C230043185B /* KRParticleSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRParticleSystem.cpp; path = Classes/KRParticleSystem.cpp; sourceTree = ""; }; + E4324BAA16444DEF0043185B /* KRParticleSystemBrownian.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRParticleSystemBrownian.h; path = Classes/KRParticleSystemBrownian.h; sourceTree = ""; }; + E4324BAD16444E120043185B /* KRParticleSystemBrownian.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRParticleSystemBrownian.cpp; path = Classes/KRParticleSystemBrownian.cpp; sourceTree = ""; }; E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRContextObject.cpp; path = Classes/KRContextObject.cpp; sourceTree = ""; }; E43B0AD515DDCA0D00A5CB9F /* KRContextObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRContextObject.h; path = Classes/KRContextObject.h; sourceTree = ""; }; E45772F113C9A13C0037BEEA /* ShadowShader.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; lineEnding = 0; name = ShadowShader.vsh; path = Shaders/ShadowShader.vsh; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.glsl; }; @@ -233,6 +249,8 @@ E45AC0331641D67300DC3C3B /* simple_blit.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = simple_blit.fsh; path = Shaders/simple_blit.fsh; sourceTree = ""; }; E45AC03E1641DE5D00DC3C3B /* debug_font.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = debug_font.vsh; path = Shaders/debug_font.vsh; sourceTree = ""; }; E45AC0411641DE6D00DC3C3B /* debug_font.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = debug_font.fsh; path = Shaders/debug_font.fsh; sourceTree = ""; }; + E45AC0461643451200DC3C3B /* particle.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = particle.fsh; path = Shaders/particle.fsh; sourceTree = ""; }; + E45AC0491643452000DC3C3B /* particle.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = particle.vsh; path = Shaders/particle.vsh; sourceTree = ""; }; E461A151152E54B500F2044A /* KRLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRLight.h; path = Classes/KRLight.h; sourceTree = ""; }; E461A155152E54F700F2044A /* KRLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRLight.cpp; path = Classes/KRLight.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; E461A157152E555400F2044A /* KRPointLight.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = KRPointLight.h; path = Classes/KRPointLight.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; @@ -368,6 +386,17 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + E4324BA916444DCB0043185B /* Particle Systems */ = { + isa = PBXGroup; + children = ( + E4324BA316444C0D0043185B /* KRParticleSystem.h */, + E4324BA716444C230043185B /* KRParticleSystem.cpp */, + E4324BAA16444DEF0043185B /* KRParticleSystemBrownian.h */, + E4324BAD16444E120043185B /* KRParticleSystemBrownian.cpp */, + ); + name = "Particle Systems"; + sourceTree = ""; + }; E45772E313C99F160037BEEA /* Shaders */ = { isa = PBXGroup; children = ( @@ -395,6 +424,8 @@ E45AC0331641D67300DC3C3B /* simple_blit.fsh */, E45AC03E1641DE5D00DC3C3B /* debug_font.vsh */, E45AC0411641DE6D00DC3C3B /* debug_font.fsh */, + E45AC0461643451200DC3C3B /* particle.fsh */, + E45AC0491643452000DC3C3B /* particle.vsh */, ); name = Shaders; sourceTree = ""; @@ -547,6 +578,7 @@ E48C696C15374A1500232E28 /* Scene Graph Nodes */ = { isa = PBXGroup; children = ( + E4324BA916444DCB0043185B /* Particle Systems */, E414BAE11435557300A668C4 /* KRInstance.h */, E414BAE41435558800A668C4 /* KRInstance.cpp */, E461A171152E599E00F2044A /* Lights */, @@ -733,6 +765,8 @@ E4CA10E51637BD0A005D9400 /* KRTexturePVR.h in Headers */, E4CA10EC1637BD47005D9400 /* KRTextureTGA.h in Headers */, E4CA11741639CBD6005D9400 /* KRViewport.h in Headers */, + E4324BA416444C0D0043185B /* KRParticleSystem.h in Headers */, + E4324BAB16444DEF0043185B /* KRParticleSystemBrownian.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -785,6 +819,8 @@ E4CA11751639CBD6005D9400 /* KRViewport.h in Headers */, E461A15D152E563100F2044A /* KRDirectionalLight.h in Headers */, E461A169152E570700F2044A /* KRSpotLight.h in Headers */, + E4324BA516444C0D0043185B /* KRParticleSystem.h in Headers */, + E4324BAC16444DEF0043185B /* KRParticleSystemBrownian.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -914,6 +950,10 @@ E45AC0341641D67300DC3C3B /* simple_blit.fsh in Sources */, E45AC03F1641DE5D00DC3C3B /* debug_font.vsh in Sources */, E45AC0421641DE6D00DC3C3B /* debug_font.fsh in Sources */, + E45AC0471643451300DC3C3B /* particle.fsh in Sources */, + E45AC04A1643452100DC3C3B /* particle.vsh in Sources */, + E4324BA816444C230043185B /* KRParticleSystem.cpp in Sources */, + E4324BAE16444E120043185B /* KRParticleSystemBrownian.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -966,6 +1006,10 @@ E45AC0351641D67300DC3C3B /* simple_blit.fsh in Sources */, E45AC0401641DE5D00DC3C3B /* debug_font.vsh in Sources */, E45AC0431641DE6D00DC3C3B /* debug_font.fsh in Sources */, + E45AC0481643451300DC3C3B /* particle.fsh in Sources */, + E45AC04B1643452100DC3C3B /* particle.vsh in Sources */, + E4324BAF16444E120043185B /* KRParticleSystemBrownian.cpp in Sources */, + E4324BB0164458930043185B /* KRParticleSystem.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/KREngine/KREngine/Classes/KRCamera.cpp b/KREngine/KREngine/Classes/KRCamera.cpp index 140effb..5d5cb72 100644 --- a/KREngine/KREngine/Classes/KRCamera.cpp +++ b/KREngine/KREngine/Classes/KRCamera.cpp @@ -41,6 +41,7 @@ #import "KRStockGeometry.h" KRCamera::KRCamera(KRContext &context) : KRContextObject(context) { + m_particlesAbsoluteTime = 0.0f; backingWidth = 0; backingHeight = 0; @@ -136,7 +137,7 @@ void KRCamera::setPosition(const KRVector3 &position) { m_position = position; } -void KRCamera::renderFrame(KRScene &scene, KRMat4 &viewMatrix) +void KRCamera::renderFrame(KRScene &scene, KRMat4 &viewMatrix, float deltaTime) { GLint defaultFBO; GLDEBUG(glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO)); @@ -196,7 +197,7 @@ void KRCamera::renderFrame(KRScene &scene, KRMat4 &viewMatrix) } } - renderFrame(scene, lightDirection); + renderFrame(scene, lightDirection, deltaTime); GLDEBUG(glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO)); renderPost(); @@ -206,7 +207,7 @@ void KRCamera::renderFrame(KRScene &scene, KRMat4 &viewMatrix) -void KRCamera::renderFrame(KRScene &scene, KRVector3 &lightDirection) { +void KRCamera::renderFrame(KRScene &scene, KRVector3 &lightDirection, float deltaTime) { KRVector3 vecCameraDirection = m_viewport.getCameraDirection(); @@ -416,7 +417,8 @@ void KRCamera::renderFrame(KRScene &scene, KRVector3 &lightDirection) { GLDEBUG(glBlendFunc(GL_ONE, GL_ONE)); // Render all flares - scene.render(this, m_visibleBounds, m_pContext, m_viewport, lightDirection, shadowmvpmatrix, shadowDepthTexture, m_cShadowBuffers, KRNode::RENDER_PASS_FLARES, newVisibleBounds); + scene.render(this, m_visibleBounds, m_pContext, m_viewport, lightDirection, shadowmvpmatrix, shadowDepthTexture, m_cShadowBuffers, KRNode::RENDER_PASS_ADDITIVE_PARTICLES, newVisibleBounds); + // ----====---- Debug Overlay ----====---- diff --git a/KREngine/KREngine/Classes/KRCamera.h b/KREngine/KREngine/Classes/KRCamera.h index 3a34783..678f9a8 100644 --- a/KREngine/KREngine/Classes/KRCamera.h +++ b/KREngine/KREngine/Classes/KRCamera.h @@ -58,7 +58,7 @@ public: GLint backingWidth, backingHeight; - void renderFrame(KRScene &scene, KRMat4 &viewMatrix); + void renderFrame(KRScene &scene, KRMat4 &viewMatrix, float deltaTime); KRVector3 getPosition() const; void setPosition(const KRVector3 &position); @@ -145,7 +145,7 @@ private: void destroyBuffers(); - void renderFrame(KRScene &scene, KRVector3 &lightDirection); + void renderFrame(KRScene &scene, KRVector3 &lightDirection, float deltaTime); @@ -180,6 +180,8 @@ private: KRViewport m_viewport; + + float m_particlesAbsoluteTime; }; #endif diff --git a/KREngine/KREngine/Classes/KREngine.h b/KREngine/KREngine/Classes/KREngine.h index 89cd509..4b454c8 100644 --- a/KREngine/KREngine/Classes/KREngine.h +++ b/KREngine/KREngine/Classes/KREngine.h @@ -67,8 +67,8 @@ typedef enum KREngineParameterType {KRENGINE_PARAMETER_INT, KRENGINE_PARAMETER_F -(void)setParameterValueWithName: (NSString *)name Value: (float)v; -(int)getParameterIndexWithName: (NSString *)name; -- (void)renderScene: (KRScene *)pScene WithViewMatrix: (KRMat4)viewMatrix; -- (void)renderScene: (KRScene *)pScene WithPosition: (KRVector3)position Yaw: (GLfloat)yaw Pitch: (GLfloat)pitch Roll: (GLfloat)roll; +- (void)renderScene: (KRScene *)pScene WithViewMatrix: (KRMat4)viewMatrix AndDeltaTime: (float)deltaTime; +- (void)renderScene: (KRScene *)pScene WithPosition: (KRVector3)position Yaw: (GLfloat)yaw Pitch: (GLfloat)pitch Roll: (GLfloat)roll AndDeltaTime: (float)deltaTime; - (void)setNearZ: (float)dNearZ; - (void)setFarZ: (float)dFarZ; diff --git a/KREngine/KREngine/Classes/KREngine.mm b/KREngine/KREngine/Classes/KREngine.mm index 28c1fc1..e0e654f 100644 --- a/KREngine/KREngine/Classes/KREngine.mm +++ b/KREngine/KREngine/Classes/KREngine.mm @@ -139,7 +139,7 @@ float const PI = 3.141592653589793f; return self; } -- (void)renderScene: (KRScene *)pScene WithPosition: (KRVector3)position Yaw: (GLfloat)yaw Pitch: (GLfloat)pitch Roll: (GLfloat)roll +- (void)renderScene: (KRScene *)pScene WithPosition: (KRVector3)position Yaw: (GLfloat)yaw Pitch: (GLfloat)pitch Roll: (GLfloat)roll AndDeltaTime: (float)deltaTime { KRMat4 viewMatrix; viewMatrix.translate(-position.x, -position.y, -position.z); @@ -147,12 +147,12 @@ float const PI = 3.141592653589793f; viewMatrix.rotate(pitch, X_AXIS); viewMatrix.rotate(roll, Z_AXIS); - [self renderScene: pScene WithViewMatrix: viewMatrix]; + [self renderScene: pScene WithViewMatrix: viewMatrix AndDeltaTime: deltaTime]; } -- (void)renderScene: (KRScene *)pScene WithViewMatrix: (KRMat4)viewMatrix +- (void)renderScene: (KRScene *)pScene WithViewMatrix: (KRMat4)viewMatrix AndDeltaTime: (float)deltaTime { - _camera->renderFrame(*pScene, viewMatrix); + _camera->renderFrame(*pScene, viewMatrix, deltaTime); } - (BOOL)loadShaders diff --git a/KREngine/KREngine/Classes/KRInstance.cpp b/KREngine/KREngine/Classes/KRInstance.cpp index 9b4e315..9609050 100644 --- a/KREngine/KREngine/Classes/KRInstance.cpp +++ b/KREngine/KREngine/Classes/KRInstance.cpp @@ -85,7 +85,7 @@ void KRInstance::render(KRCamera *pCamera, KRContext *pContext, const KRViewport KRNode::render(pCamera, pContext, viewport, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass); - if(renderPass != KRNode::RENDER_PASS_DEFERRED_LIGHTS && (renderPass != KRNode::RENDER_PASS_FORWARD_TRANSPARENT || this->hasTransparency()) && renderPass != KRNode::RENDER_PASS_FLARES) { + if(renderPass != KRNode::RENDER_PASS_DEFERRED_LIGHTS && (renderPass != KRNode::RENDER_PASS_FORWARD_TRANSPARENT || this->hasTransparency()) && renderPass != KRNode::RENDER_PASS_ADDITIVE_PARTICLES) { // Don't render meshes on second pass of the deferred lighting renderer, as only lights will be applied loadModel(); diff --git a/KREngine/KREngine/Classes/KRLight.cpp b/KREngine/KREngine/Classes/KRLight.cpp index 86c650a..ebee15d 100644 --- a/KREngine/KREngine/Classes/KRLight.cpp +++ b/KREngine/KREngine/Classes/KRLight.cpp @@ -122,7 +122,7 @@ void KRLight::render(KRCamera *pCamera, KRContext *pContext, const KRViewport &v KRNode::render(pCamera, pContext, viewport, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass); - if(renderPass == KRNode::RENDER_PASS_FLARES) { + if(renderPass == KRNode::RENDER_PASS_ADDITIVE_PARTICLES) { if(m_flareTexture.size() && m_flareSize > 0.0f) { if(!m_pFlareTexture && m_flareTexture.size()) { m_pFlareTexture = pContext->getTextureManager()->getTexture(m_flareTexture.c_str()); @@ -135,6 +135,10 @@ void KRLight::render(KRCamera *pCamera, KRContext *pContext, const KRViewport &v KRMat4 m_modelMatrix = KRMat4(); m_modelMatrix.translate(light_position.x, light_position.y, light_position.z); + // Disable z-buffer test + GLDEBUG(glDisable(GL_DEPTH_TEST)); + GLDEBUG(glDepthRangef(0.0, 1.0)); + // Render light flare on transparency pass KRShader *pShader = pContext->getShaderManager()->getShader("flare", pCamera, false, false, false, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass); if(pShader->bind(viewport, m_modelMatrix, lightDirection, pShadowMatrices, shadowDepthTextures, 0, renderPass)) { diff --git a/KREngine/KREngine/Classes/KRModel.cpp b/KREngine/KREngine/Classes/KRModel.cpp index e917d98..fcd0190 100644 --- a/KREngine/KREngine/Classes/KRModel.cpp +++ b/KREngine/KREngine/Classes/KRModel.cpp @@ -114,7 +114,7 @@ void KRModel::loadPack(KRDataBlock *data) { void KRModel::render(KRCamera *pCamera, KRContext *pContext, const KRViewport &viewport, KRMat4 &matModel, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRTexture *pLightMap, KRNode::RenderPass renderPass) { //fprintf(stderr, "Rendering model: %s\n", m_name.c_str()); - if(renderPass != KRNode::RENDER_PASS_FLARES) { + if(renderPass != KRNode::RENDER_PASS_ADDITIVE_PARTICLES) { if(m_materials.size() == 0) { vector submeshes = getSubmeshes(); @@ -303,7 +303,7 @@ void KRModel::LoadData(std::vector vertices, std::vector u pack_material *pPackMaterial = pPackMaterials + iMaterial; pPackMaterial->start_vertex = submesh_starts[iMaterial]; pPackMaterial->vertex_count = submesh_lengths[iMaterial]; - strncpy(pPackMaterial->szName, material_names[iMaterial].c_str(), 63); + strncpy(pPackMaterial->szName, material_names[iMaterial].c_str(), 256); } bool bFirstVertex = true; diff --git a/KREngine/KREngine/Classes/KRModelManager.cpp b/KREngine/KREngine/Classes/KRModelManager.cpp index 53a964a..17b2fc6 100644 --- a/KREngine/KREngine/Classes/KRModelManager.cpp +++ b/KREngine/KREngine/Classes/KRModelManager.cpp @@ -39,6 +39,7 @@ KRModelManager::KRModelManager(KRContext &context) : KRContextObject(context) { m_currentVBO.vao_handle = 0; m_currentVBO.data = NULL; m_vboMemUsed = 0; + m_randomParticleVertexData = NULL; } KRModelManager::~KRModelManager() { @@ -46,6 +47,7 @@ KRModelManager::~KRModelManager() { delete (*itr).second; } m_models.empty(); + if(m_randomParticleVertexData != NULL) delete m_randomParticleVertexData; } KRModel *KRModelManager::loadModel(const char *szName, KRDataBlock *pData) { @@ -246,3 +248,36 @@ void KRModelManager::rotateBuffers(bool new_frame) } } + +KRModelManager::RandomParticleVertexData *KRModelManager::getRandomParticles() +{ + const int MAX_PARTICLES=500000; + if(m_randomParticleVertexData == NULL) { + m_randomParticleVertexData = (RandomParticleVertexData *)malloc(sizeof(RandomParticleVertexData) * MAX_PARTICLES * 3); + + int iVertex=0; + for(int iParticle=0; iParticle < MAX_PARTICLES; iParticle++) { + m_randomParticleVertexData[iVertex].vertex.x = (float)(arc4random() % 2000) / 1000.0f - 1.0f; + m_randomParticleVertexData[iVertex].vertex.y = (float)(arc4random() % 2000) / 1000.0f - 1.0f; + m_randomParticleVertexData[iVertex].vertex.z = (float)(arc4random() % 2000) / 1000.0f - 1.0f; + m_randomParticleVertexData[iVertex].uva.u = 0.0f; + m_randomParticleVertexData[iVertex].uva.v = 0.0f; + iVertex++; + + m_randomParticleVertexData[iVertex].vertex.x = m_randomParticleVertexData[iVertex-1].vertex.x; + m_randomParticleVertexData[iVertex].vertex.y = m_randomParticleVertexData[iVertex-1].vertex.y; + m_randomParticleVertexData[iVertex].vertex.z = m_randomParticleVertexData[iVertex-1].vertex.z; + m_randomParticleVertexData[iVertex].uva.u = 1.0f; + m_randomParticleVertexData[iVertex].uva.v = 0.0f; + iVertex++; + + m_randomParticleVertexData[iVertex].vertex.x = m_randomParticleVertexData[iVertex-1].vertex.x; + m_randomParticleVertexData[iVertex].vertex.y = m_randomParticleVertexData[iVertex-1].vertex.y; + m_randomParticleVertexData[iVertex].vertex.z = m_randomParticleVertexData[iVertex-1].vertex.z; + m_randomParticleVertexData[iVertex].uva.u = 0.5f; + m_randomParticleVertexData[iVertex].uva.v = 1.0f; + iVertex++; + } + } + return m_randomParticleVertexData; +} diff --git a/KREngine/KREngine/Classes/KRModelManager.h b/KREngine/KREngine/Classes/KRModelManager.h index a4c7ab4..2dd0e2a 100644 --- a/KREngine/KREngine/Classes/KRModelManager.h +++ b/KREngine/KREngine/Classes/KRModelManager.h @@ -63,6 +63,25 @@ public: void configureAttribs(bool enable_vertex, bool enable_normal, bool enable_tangent, bool enable_uva, bool enable_uvb); + + typedef struct { + GLfloat x; + GLfloat y; + GLfloat z; + } KRVector3D; + + typedef struct { + GLfloat u; + GLfloat v; + } TexCoord; + + typedef struct { + KRVector3D vertex; + TexCoord uva; + } RandomParticleVertexData; + + RandomParticleVertexData *getRandomParticles(); + private: std::multimap m_models; // Multiple models with the same name/key may be inserted, representing multiple LOD levels of the model @@ -78,6 +97,8 @@ private: std::map m_vbosActive; std::map m_vbosPool; + + RandomParticleVertexData *m_randomParticleVertexData; }; #endif diff --git a/KREngine/KREngine/Classes/KRNode.cpp b/KREngine/KREngine/Classes/KRNode.cpp index f44f6fe..2c23776 100644 --- a/KREngine/KREngine/Classes/KRNode.cpp +++ b/KREngine/KREngine/Classes/KRNode.cpp @@ -15,6 +15,8 @@ #import "KRSpotLight.h" #import "KRDirectionalLight.h" #import "KRInstance.h" +#import "KRParticleSystem.h" +#import "KRParticleSystemBrownian.h" #import "KRAABB.h" @@ -136,6 +138,8 @@ KRNode *KRNode::LoadXML(KRScene &scene, tinyxml2::XMLElement *e) { new_node = new KRDirectionalLight(scene, szName); } else if(strcmp(szElementName, "spot_light") == 0) { new_node = new KRSpotLight(scene, szName); + } else if(strcmp(szElementName, "brownian_particles") == 0) { + new_node = new KRParticleSystemBrownian(scene, szName); } else if(strcmp(szElementName, "mesh") == 0) { float lod_min_coverage = 0.0f; if(e->QueryFloatAttribute("lod_min_coverage", &lod_min_coverage) != tinyxml2::XML_SUCCESS) { diff --git a/KREngine/KREngine/Classes/KRNode.h b/KREngine/KREngine/Classes/KRNode.h index a378740..2f4a8f0 100644 --- a/KREngine/KREngine/Classes/KRNode.h +++ b/KREngine/KREngine/Classes/KRNode.h @@ -6,8 +6,8 @@ // Copyright (c) 2012 Kearwood Software. All rights reserved. // -#ifndef KREngine_KRNode_h -#define KREngine_KRNode_h +#ifndef KRNODE_H +#define KRNODE_H #import "KRResource.h" #import "KRVector3.h" @@ -33,7 +33,7 @@ public: RENDER_PASS_DEFERRED_LIGHTS, RENDER_PASS_DEFERRED_OPAQUE, RENDER_PASS_FORWARD_TRANSPARENT, - RENDER_PASS_FLARES, + RENDER_PASS_ADDITIVE_PARTICLES, RENDER_PASS_SHADOWMAP }; diff --git a/KREngine/KREngine/Classes/KRParticleSystem.cpp b/KREngine/KREngine/Classes/KRParticleSystem.cpp new file mode 100644 index 0000000..a0e242b --- /dev/null +++ b/KREngine/KREngine/Classes/KRParticleSystem.cpp @@ -0,0 +1,31 @@ +// +// KRParticleSystem.cpp +// KREngine +// +// Created by Kearwood Gilbert on 2012-11-02. +// Copyright (c) 2012 Kearwood Software. All rights reserved. +// + +#include "KRParticleSystem.h" + +KRParticleSystem::KRParticleSystem(KRScene &scene, std::string name) : KRNode(scene, name) +{ + +} + +KRParticleSystem::~KRParticleSystem() +{ + +} + +void KRParticleSystem::loadXML(tinyxml2::XMLElement *e) +{ + +} + +tinyxml2::XMLElement *KRParticleSystem::saveXML( tinyxml2::XMLNode *parent) +{ + tinyxml2::XMLElement *e = KRNode::saveXML(parent); + return e; +} + diff --git a/KREngine/KREngine/Classes/KRParticleSystem.h b/KREngine/KREngine/Classes/KRParticleSystem.h new file mode 100644 index 0000000..35bf241 --- /dev/null +++ b/KREngine/KREngine/Classes/KRParticleSystem.h @@ -0,0 +1,28 @@ +// +// KRParticleSystem.h +// KREngine +// +// Created by Kearwood Gilbert on 2012-11-02. +// Copyright (c) 2012 Kearwood Software. All rights reserved. +// + +#ifndef KRPARTICLESYSTEM_H +#define KRPARTICLESYSTEM_H + +#import "KRNode.h" + +class KRParticleSystem : public KRNode { +public: + virtual ~KRParticleSystem(); + + virtual std::string getElementName() = 0; + virtual void loadXML(tinyxml2::XMLElement *e); + virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent); + +protected: + KRParticleSystem(KRScene &scene, std::string name); +private: + +}; + +#endif diff --git a/KREngine/KREngine/Classes/KRParticleSystemBrownian.cpp b/KREngine/KREngine/Classes/KRParticleSystemBrownian.cpp new file mode 100644 index 0000000..439e7dc --- /dev/null +++ b/KREngine/KREngine/Classes/KRParticleSystemBrownian.cpp @@ -0,0 +1,71 @@ +// +// KRParticleSystemBrownian.cpp +// KREngine +// +// Created by Kearwood Gilbert on 2012-11-02. +// Copyright (c) 2012 Kearwood Software. All rights reserved. +// + +#include "KRParticleSystemBrownian.h" + +KRParticleSystemBrownian::KRParticleSystemBrownian(KRScene &scene, std::string name) : KRParticleSystem(scene, name) +{ + +} + +KRParticleSystemBrownian::~KRParticleSystemBrownian() +{ + +} + +std::string KRParticleSystemBrownian::getElementName() +{ + return "brownian_particles"; +} + +void KRParticleSystemBrownian::loadXML(tinyxml2::XMLElement *e) +{ + KRParticleSystem::loadXML(e); +} + +tinyxml2::XMLElement *KRParticleSystemBrownian::saveXML( tinyxml2::XMLNode *parent) +{ + tinyxml2::XMLElement *e = KRParticleSystem::saveXML(parent); + return e; +} + + +// +// m_particlesAbsoluteTime += deltaTime; +// +// // Enable z-buffer test +// GLDEBUG(glEnable(GL_DEPTH_TEST)); +// GLDEBUG(glDepthRangef(0.0, 1.0)); +// +// KRTexture *pParticleTexture = m_pContext->getTextureManager()->getTexture("flare"); +// m_pContext->getTextureManager()->selectTexture(0, pParticleTexture, 2048); +// +// KRShader *pParticleShader = m_pContext->getShaderManager()->getShader("particle", this, false, false, false, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_ADDITIVE_PARTICLES); +// +// KRMat4 particleModelMatrix = KRMat4(); +//// particleModelMatrix.scale(particleBlockScale); +//// +//// KRVector3 particleBlockOrigin = KRVector3(m_viewport.getCameraPosition().x - fmod(m_viewport.getCameraPosition().x + x * particleBlockScale, particleBlockScale), m_viewport.getCameraPosition().y - fmod(m_viewport.getCameraPosition().y + y * particleBlockScale, particleBlockScale),m_viewport.getCameraPosition().z - fmod(m_viewport.getCameraPosition().z + z * particleBlockScale, particleBlockScale)); +//// +//// particleModelMatrix.translate(particleBlockOrigin); +//// particleModelMatrix.translate(sin(m_particlesAbsoluteTime * 0.0523f) * 10.0f, sin(m_particlesAbsoluteTime * 0.0553f) * 10.0f, sin(m_particlesAbsoluteTime * 0.0521f) * 10.0f); +// +// int particle_count = 10000; +// +// if(pParticleShader->bind(m_viewport, particleModelMatrix, lightDirection, shadowmvpmatrix, shadowDepthTexture, m_cShadowBuffers, KRNode::RENDER_PASS_ADDITIVE_PARTICLES)) { +// GLDEBUG(glUniform1f( +// pParticleShader->m_uniforms[KRShader::KRENGINE_UNIFORM_FLARE_SIZE], +// 1.0f +// )); +// +// m_pContext->getModelManager()->bindVBO((void *)m_pContext->getModelManager()->getRandomParticles(), particle_count * 3 * sizeof(KRModelManager::RandomParticleVertexData), true, false, false, true, false); +// GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, particle_count*3)); +// } +//// } +//// } +//// } \ No newline at end of file diff --git a/KREngine/KREngine/Classes/KRParticleSystemBrownian.h b/KREngine/KREngine/Classes/KRParticleSystemBrownian.h new file mode 100644 index 0000000..3c3d568 --- /dev/null +++ b/KREngine/KREngine/Classes/KRParticleSystemBrownian.h @@ -0,0 +1,26 @@ +// +// KRParticleSystemBrownian.h +// KREngine +// +// Created by Kearwood Gilbert on 2012-11-02. +// Copyright (c) 2012 Kearwood Software. All rights reserved. +// + +#ifndef KRPARTICLESYSTEMBROWNIAN_H +#define KRPARTICLESYSTEMBROWNIAN_H + +#import "KRParticleSystem.h" + +class KRParticleSystemBrownian : public KRParticleSystem { +public: + KRParticleSystemBrownian(KRScene &scene, std::string name); + virtual ~KRParticleSystemBrownian(); + + virtual std::string getElementName(); + virtual void loadXML(tinyxml2::XMLElement *e); + virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent); +private: + +}; + +#endif diff --git a/KREngine/KREngine/Classes/KRResource+fbx.cpp b/KREngine/KREngine/Classes/KRResource+fbx.cpp index 72befea..23be486 100644 --- a/KREngine/KREngine/Classes/KRResource+fbx.cpp +++ b/KREngine/KREngine/Classes/KRResource+fbx.cpp @@ -267,23 +267,6 @@ void LoadNode(KRNode *parent_node, std::vector &resources, KFbxGeo } void LoadMesh(KRNode *parent_node, std::vector &resources, KFbxGeometryConverter *pGeometryConverter, KFbxNode* pNode) { - std::string light_map = pNode->GetName(); - light_map.append("_lightmap"); - - KRInstance *new_instance = new KRInstance(parent_node->getScene(), pNode->GetName(), pNode->GetName(), light_map, 0.0f); - fbxDouble3 local_rotation = pNode->LclRotation.Get(); // pNode->GetGeometricRotation(KFbxNode::eSOURCE_SET); - fbxDouble3 local_translation = pNode->LclTranslation.Get(); // pNode->GetGeometricTranslation(KFbxNode::eSOURCE_SET); - fbxDouble3 local_scale = pNode->LclScaling.Get(); // pNode->GetGeometricScaling(KFbxNode::eSOURCE_SET); - /* - fbxDouble3 local_rotation = pNode->GetGeometricRotation(KFbxNode::eDESTINATION_SET); - fbxDouble3 local_translation = pNode->GetGeometricTranslation(KFbxNode::eDESTINATION_SET); - fbxDouble3 local_scale = pNode->GetGeometricScaling(KFbxNode::eDESTINATION_SET); - */ - new_instance->setLocalRotation(KRVector3(local_rotation[0], local_rotation[1], local_rotation[2])); - new_instance->setLocalTranslation(KRVector3(local_translation[0], local_translation[1], local_translation[2])); - new_instance->setLocalScale(KRVector3(local_scale[0], local_scale[1], local_scale[2])); - parent_node->addChild(new_instance); - printf("Mesh: %s\n", pNode->GetName()); KFbxMesh* pSourceMesh = (KFbxMesh*) pNode->GetNodeAttribute(); @@ -582,6 +565,26 @@ void LoadMesh(KRNode *parent_node, std::vector &resources, KFbxGeo KRModel *new_mesh = new KRModel(parent_node->getContext(), pNode->GetName()); new_mesh->LoadData(vertices, uva, uvb, normals, tangents, submesh_starts, submesh_lengths, material_names); resources.push_back(new_mesh); + + if(new_mesh->getLODCoverage() == 100) { + // If this is the full detail model, add an instance of it to the scene file + std::string light_map = pNode->GetName(); + light_map.append("_lightmap"); + + KRInstance *new_instance = new KRInstance(parent_node->getScene(), pNode->GetName(), pNode->GetName(), light_map, 0.0f); + fbxDouble3 local_rotation = pNode->LclRotation.Get(); // pNode->GetGeometricRotation(KFbxNode::eSOURCE_SET); + fbxDouble3 local_translation = pNode->LclTranslation.Get(); // pNode->GetGeometricTranslation(KFbxNode::eSOURCE_SET); + fbxDouble3 local_scale = pNode->LclScaling.Get(); // pNode->GetGeometricScaling(KFbxNode::eSOURCE_SET); + /* + fbxDouble3 local_rotation = pNode->GetGeometricRotation(KFbxNode::eDESTINATION_SET); + fbxDouble3 local_translation = pNode->GetGeometricTranslation(KFbxNode::eDESTINATION_SET); + fbxDouble3 local_scale = pNode->GetGeometricScaling(KFbxNode::eDESTINATION_SET); + */ + new_instance->setLocalRotation(KRVector3(local_rotation[0], local_rotation[1], local_rotation[2])); + new_instance->setLocalTranslation(KRVector3(local_translation[0], local_translation[1], local_translation[2])); + new_instance->setLocalScale(KRVector3(local_scale[0], local_scale[1], local_scale[2])); + parent_node->addChild(new_instance); + } } diff --git a/KREngine/KREngine/Classes/KRScene.cpp b/KREngine/KREngine/Classes/KRScene.cpp index 54d8f16..3c4096f 100644 --- a/KREngine/KREngine/Classes/KRScene.cpp +++ b/KREngine/KREngine/Classes/KRScene.cpp @@ -224,7 +224,7 @@ void KRScene::render(KROctreeNode *pOctreeNode, std::set &visibleBounds, KRMat4 mvpmatrix = matModel * viewport.getViewProjectionMatrix(); // Enable additive blending - if(renderPass != KRNode::RENDER_PASS_FORWARD_TRANSPARENT && renderPass != KRNode::RENDER_PASS_FLARES) { + if(renderPass != KRNode::RENDER_PASS_FORWARD_TRANSPARENT && renderPass != KRNode::RENDER_PASS_ADDITIVE_PARTICLES) { GLDEBUG(glEnable(GL_BLEND)); } GLDEBUG(glBlendFunc(GL_ONE, GL_ONE)); @@ -254,7 +254,7 @@ void KRScene::render(KROctreeNode *pOctreeNode, std::set &visibleBounds, pOctreeNode->endOcclusionQuery(); - if(renderPass != KRNode::RENDER_PASS_FORWARD_TRANSPARENT && renderPass != KRNode::RENDER_PASS_FLARES) { + if(renderPass != KRNode::RENDER_PASS_FORWARD_TRANSPARENT && renderPass != KRNode::RENDER_PASS_ADDITIVE_PARTICLES) { GLDEBUG(glDisable(GL_BLEND)); } else if(renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT) { GLDEBUG(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); @@ -279,7 +279,7 @@ void KRScene::render(KROctreeNode *pOctreeNode, std::set &visibleBounds, (*itr)->render(pCamera, pContext, viewport, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass); } - const int *childOctreeOrder = renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT || renderPass == KRNode::RENDER_PASS_FLARES ? viewport.getBackToFrontOrder() : viewport.getFrontToBackOrder(); + const int *childOctreeOrder = renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT || renderPass == KRNode::RENDER_PASS_ADDITIVE_PARTICLES ? viewport.getBackToFrontOrder() : viewport.getFrontToBackOrder(); for(int i=0; i<8; i++) { render(pOctreeNode->getChildren()[childOctreeOrder[i]], visibleBounds, pCamera, pContext, viewport, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass, remainingOctrees, remainingOctreesTestResults, remainingOctreesTestResultsOnly, newVisibleBounds, false, false); diff --git a/KREngine/KREngine/Shaders/particle.fsh b/KREngine/KREngine/Shaders/particle.fsh new file mode 100644 index 0000000..8a887d5 --- /dev/null +++ b/KREngine/KREngine/Shaders/particle.fsh @@ -0,0 +1,38 @@ +// +// particle.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; + +void main() { + gl_FragColor = vec4(vec3(texture2D(diffuseTexture, texCoord)), 1.0); + //gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); +} \ No newline at end of file diff --git a/KREngine/KREngine/Shaders/particle.vsh b/KREngine/KREngine/Shaders/particle.vsh new file mode 100644 index 0000000..4b851b5 --- /dev/null +++ b/KREngine/KREngine/Shaders/particle.vsh @@ -0,0 +1,43 @@ +// +// particle.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; +attribute vec4 vertex_position; + +varying mediump vec2 texCoord; + +void main() { + texCoord = vertex_uv; + gl_Position = mvp_matrix * vertex_position + 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; +}