Jump to content

  • Log In with Google      Sign In   
  • Create Account

AverageJoeSSU

Member Since 30 Jun 2007
Offline Last Active Jan 25 2015 01:27 AM

Topics I've Started

[Solved] My attempt at bindless textures not working....

19 January 2015 - 10:21 PM

EDIT: stupid shader in/out blocks didnt match... thanks compiler!

 

Here is the output for my program, i also checked in gDebugger and the texture loads just fine.

 

Vendor: 4.4.0 NVIDIA 343.36
Supported GLSL version is 4.40 NVIDIA via Cg compiler.
Aspect Ratio: 2.400000 
vbo: 1
index buffer: 2
Shader Source: #version 440
 
layout (location = 0) in vec3 VertexPosition;
layout (location = 1) in vec2 TexCoords;
 
uniform mat4 worldMatrix;
uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;
 
out block
{
    vec2 Texcoord;
} Out;
 
void main()
{
    mat4 mvp = projectionMatrix * viewMatrix * worldMatrix;
    Out.Texcoord = vec2(TexCoords.x, 1.0-TexCoords.y);
    gl_Position = mvp * vec4(VertexPosition, 1.0);
}
 
../shaders/simpleTexture.vert Compilation Successful 
Shader Source: #version 440
//#extension GL_NV_gpu_shader5 : require    // for 64-bit integer types
#extension GL_ARB_bindless_texture : require
 
in block
{
    vec2 texCoords;
} In;
 
layout (bindless_sampler) uniform sampler2D textureID;
 
layout (location = 0) out vec4 FragColor;
 
void main()
{
    FragColor = texture(textureID, In.texCoords);
}
 
../shaders/simpleTexture.frag Compilation Successful 
Linking Shader Program: simpleTexture.vert
Shader Link Successful
GL_ACTIVE_UNIFORMS = 4
  0) type:mat4 name:projectionMatrix location:0
  1) type:sampler2D name:textureID location:1
  2) type:mat4 name:viewMatrix location:2
  3) type:mat4 name:worldMatrix location:3
width: 500, height 331: 
Done Loading Texture... 
SOIL loading error: 'Image loaded'
texture handle pointer: 4294969856
 
 
My question is, given those shaders and the fact that glGetTextureHandleARB returns non 0, should it work? (of course given the correct geometry and uvs)
 

please review my C++11 Chrono render/game loop?

16 January 2015 - 12:53 PM

I am struggling to get a buttery smooth framerate with chrono.

 

I have a simple animated rectangle that is adding an angle (multipled by delta time) to a sin wave and after seemingly random intervals of time i get a blip. (anywhere between 10 seconds and 5 minutes).

 

Here is my loop (based on Gaffers Fix your timestep!)

using namespace std::chrono;
using Clock = high_resolution_clock;
    init();

    auto kMaxDeltatime = duration<long,std::ratio<1,60>>(1);
    auto lastEndTime = Clock::now();
    auto accumulator = microseconds(0);
    while (!glfwWindowShouldClose(tsxWindow->window)) {
        auto newEndTime = Clock::now();
        const auto frameTime = newEndTime - lastEndTime;
        lastEndTime = newEndTime;
        accumulator += duration_cast<microseconds>(frameTime);

        while ( accumulator >= kMaxDeltatime )
        {
            //accumulator -= duration_cast<microseconds>(kMaxDeltatime);
            Update(duration_cast<milliseconds>(frameTime).count());
            accumulator -= duration_cast<microseconds>(frameTime);
        }
        Draw(duration_cast<milliseconds>(kMaxDeltatime).count());
        glfwPollEvents();
    }

and my objects update:

void Object::Update(long delta_time) {

    angle += 0.05 * (float)delta_time;
    angle = fmod(angle,360);
    double scale = 1;
    transformWorld = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f));
    transformWorld = glm::translate(transformWorld, glm::vec3(sin(angle*PI/180.0)*scale, 0.0f, 0.0f));
//    fprintf(stdout, "deltatime: %ld \n angle: %f \n WorldTransform: \n %s \n", delta_time, angle, glm::to_string(transformWorld).c_str());
//    fflush(stdout);
}

and my smoothness is best with a high resolution clock (not a steady one) but even still after a long while (~5 minutes) it can stutter (not tear).

 

I am using linux and clang++ (swap interval is 1).


GL_ACTIVE_UNIFORMS returns 0 after successful link, locations are -1.

29 December 2014 - 10:29 PM

I am stumped, i have tried various ways (old ways and explicit). all seem to not be working.

 

here is my shader code, very simple

#version 440

layout (location = 0) in vec3 VertexPosition;
layout (location = 1) in vec2 TexCoords;

layout(location = 2) uniform mat4 worldMatrix;
layout(location = 3) uniform mat4 projectionMatrix;
layout(location = 4) uniform mat4 viewMatrix;

void main()
{
    mat4 mvp = projectionMatrix * viewMatrix * worldMatrix;
    gl_Position = mvp * vec4(VertexPosition, 1.0);
    //gl_Position = vec4(1.0, 1.0 , 1.0, 1.0);
}

and the code after the successful link:

fprintf(stdout, "Shader Link Successful\n");
fflush(stdout);

uniforms = new std::map<std::string, GLint>();

GLint location;
location = glGetUniformLocation(ShaderProgram, "worldMatrix");

ive tried without the explicit, i've tried calling glUseProgram and THEN getting the locations, nothing seems to work.

 

I AM using glew, I'm assuming there are no issues there since my shader program actually runs and the pixel shader outputs what i expect. The output of the vertex shader is as if those uniforms are all identity.

 

any ideas?

 


Calculate Position as 0 to 1 between two planes.

12 February 2014 - 06:44 PM

I'm struggling to understand the equation on page 55 of the following paper.

 

http://web.cs.wpi.edu/~rich/courses/imgd4000-d10/lectures/camera.pdf

 

the previous page 54 explains the premise behind the equation.

 

Here is my code in Unity3d to try and reproduce it:

zForward = new Vector4(gameObject.transform.forward.x,gameObject.transform.forward.y,gameObject.transform.forward.z,0);
        plane = new Vector4(gameObject.transform.up.x, gameObject.transform.up.y, gameObject.transform.up.z, 0);

Vector4 playerPos = new Vector4(player.transform.position.x,player.transform.position.y,player.transform.position.z,1);

Debug.Log(Vector4.Dot(plane,playerPos)/Vector4.Dot(plane,zForward));

gameObject has a collider that is triggered when the player walks in it. I then try to calculate the field from that paper...

 

The author suggests that the math in the equation is wrong, but i'm not sure what he is trying to do WITH that exact math there. seems to me like it is missing some sort of position or something of the plane??? just a guess.


Reflecting on implmenting coroutines in a massively state driven game.

06 February 2014 - 12:20 PM

I am full steam ahead with a game I am making with a team, and we are approaching the point of no return on one of our subsystems/architectural choices, and my lack of experience with it is frightening me.

 

It is Coroutines. We have implemented our state management using coroutines, and while i feel we have an excellent grasp of exactly how Coroutines in Unity behave, I am not, as you would say in poker, "all in" quite yet.

 

The main thing that bugs me, is that while Coroutines make state switching so so easy, there are a couple of operations that become non trivial (at least i think they are non trivial, maybe I'm wrong). The best way to describe our implementation using Coroutines is that it is a State Stack, with the option of having another state run in parallel. This description is terrible as the very word "State" is misused, but alas i think you get the point.

 

The issue at hand with a State Stack is our ability to plain ole switch to x state from y state where y is not above/below x on the stack.

 

It requires a check in every state between the two in order to make that switch. Now, in a JRPG, this might be fine, as mostly you progress from one state to another, and in a very few cases need to change to something as I previously described.

 

To that end i have provided an interface IState, which has prepare, validate, and clean methods. Every state in the game must prepare values for the state to run, and every frame validate that it is the correct state to be in, and on exit, clean itself up. The saving grace of the above is the Validate() method, for it will allow multi-state traversal across a stack. And if we take care as to how we cleanup a state (for example all Major state transitions: ExploreMode, CombatMode, WorldView Mode, Menus. If all of these modes cleanup with fading out the camera, then theoretically they all can go from one to another with no problem.)

 

Anyways, I certainly do not want to turn this into a rant smile.png. Thanks for reading and any thoughts are welcome!


PARTNERS