Jump to content

  • Log In with Google      Sign In   
  • Create Account

akaitora

Member Since 05 Sep 2008
Offline Last Active Dec 17 2015 12:12 PM

Topics I've Started

We released Deer Hunter 2016!

20 September 2015 - 01:06 AM

Hey guys! My team just released our latest creation, "Deer Hunter 2016". We managed to get featured in the iTunes, Google Play, and Amazon stores.  It is available on both iOS and Android platforms.
 
 
iTunes
 
Google Play
 
Amazon
 

Corrupted Vertex Buffer

12 September 2015 - 05:52 PM

Hi!  I am  trying to render 2 vertex buffers.  Each is setup a bit different.  The first only has positions whereas the second has both positions and uv coordinates.  If I only try to render one, the one I render looks great.  It doesn't matter which I render.  But if I render both together,  both vertex buffer become corrupt.  On screen, they both look like triangles even though they are suppose to be quads.  When I try making both use the same vertex format,  (I.E. verts and uvs) they render correctly.  This almost makes me think that they are somehow referencing each other somehow which is breaking the stride.  I am not explicitly unbinding my VBOs.  According to the OpenGL docs, I shouldn't need to.  However even when I do, it causes a crash.  Below are the classes for the 2 VBOs in question.

 

#include "QuadGeometry.h"
 
#include <iostream>
using namespace std;
 
const float QuadGeometry::verts[] =
{
    -1.0f, 1.0f, 0.0f,
    -1.0f, -1.0f, 0.0f,
    1.0f, -1.0f, 0.0f,
    -1.0f, 1.0f, 0.0f,
    1.0, 1.0, 0.0f
};
 
//---------------------------------------------------------------------
void QuadGeometry::Initialize()
{
    glGenBuffers(1, &vertexBuffer);
    glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
    glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STATIC_DRAW);
}
 
//---------------------------------------------------------------------
void QuadGeometry::Render()
{
    glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 5);
}

 

 

//---------------------------------------------------------------------
DisplayText::DisplayText()
{
    shaderFx = new ShaderFx();
    shaderFx->Load( "shaders/font/vertex.glsl", "shaders/font/fragment.glsl", true );
    
    vertexBuffer = 0;
    
    textureSurface = nullptr;
    textureSurface = SDL_LoadBMP("assets/textures/ddrsmall.bmp");
    if( !textureSurface )
    {
        cout<< "Failed to Load Texture!\n";
    }
    
    /*
    glGenTextures(1, &textureId);
    glBindTexture(GL_TEXTURE_2D, textureId);
    
    glTexImage2D(GL_TEXTURE_2D , 0 , 3 , textureSurface->w,
                 textureSurface->h , 0 , GL_RGB , GL_UNSIGNED_BYTE ,
                 textureSurface->pixels);
    
    glTexParameteri(GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER , GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER , GL_LINEAR);
    */
}
 
//---------------------------------------------------------------------
void DisplayText::CreateNewVertexBuffer()
{
    float verts[] =
    {
        //x    //y    //z   //u   //v
        -1.0f,  1.0f,  0.0f, 0.0,  1.0,
        -1.0f, -1.0f,  0.0f, 0.0,  0.0,
         1.0f, -1.0f,  0.0f, 1.0,  0.0,
        -1.0f,  1.0f,  0.0f, 0.0,  1.0,
         1.0f,  1.0f,  0.0f, 1.0,  1.0
    };
    
    glGenBuffers(1, &vertexBuffer);
    glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
    glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STATIC_DRAW);
}
 
 
//---------------------------------------------------------------------
void DisplayText::DrawString(std::string string, int x, int y)
{
    if( vertexBuffer <= 0 )
    {
        CreateNewVertexBuffer();
    }
    
    shaderFx->BeginPass();
    
    glm::mat4 Projection = glm::perspective(45.0f, 800.0f/600.0f, 0.1f, 1000.f);
    glm::mat4 View = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -7.0f));
    glm::mat4 Model = glm::scale(glm::mat4(1.0f), glm::vec3(1.0f));
    glm::mat4 modelViewMat = View * Model;
    
    shaderFx->SetMatrix4x4Parameter("modelViewMatrix", &modelViewMat[0][0]);
    shaderFx->SetMatrix4x4Parameter("projectionMatrix", &Projection[0][0]);
    
    glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 5);
    
    shaderFx->EndPass();
    
    oldString = string;
}

 

Any ideas would be helpful!  Thanks!


Procedurally Generating Noise in a Shader

28 August 2015 - 01:46 AM

Tonight I wrote a tutorial explaining how to procedurally generate noise in a shader if you need to.

 

Take a look here.

http://glslsandbox.com/e#27370.3

 

I hope it helps someone!  =)

 

procedural_noise.png

 


Picking a Random Uniformly Distributed Point in a Circle

22 June 2015 - 10:56 PM

A short article tI wrote that attempts to give a little insight into how this is done mathematically.

 

http://xdpixel.com/random-points-in-a-circle/

 

RandomPointInCircleComparison1.png


Roughness in a Reflection

09 June 2015 - 10:46 AM

I came across this site

 

http://www.chocofur.com/6-shadersamptextures.html

 

And I want to write a shader that uses a cubemap for reflection but I want to take into account the roughness of the reflection.  Essentially it looks like the roughness more or less blurs the texture.  This model seems to be used in Physically based shaders.  I am curious if anyone can point me to an article that explains the formula for adding roughness to augment a reflection vector in a shader.  Thanks!


PARTNERS