Jump to content

Second Coord Set Not Working


SpiderPig
 Share

Go to solution Solved by Josh,

Recommended Posts

Here's a quick program and shader to test this out.  The shader works with inTexCoords.xy but not with inTexCoords.zw.

#include "UltraEngine.h"
#include "Components/Mover.hpp"

using namespace UltraEngine;


int main(int argc, const char* argv[])
{
    auto displays = GetDisplays();
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    auto world = CreateWorld();

    //Create a framebuffer
    auto framebuffer = CreateFramebuffer(window);

    //Create a camera
    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125);
    camera->SetFov(70);
    camera->SetPosition(0, 0, -3);

    //Create a light
    auto light = CreateBoxLight(world);
    light->SetRotation(35, 45, 0);
    light->SetRange(-10, 10);

    auto box = CreatePlane(world);
    box->SetRotation(-90.0f, 0.0f, 0.0f);

    auto material = LoadMaterial("Materials\\Test.mat");
    box->SetMaterial(material);

    auto mesh = box->lods[0]->meshes[0];
    mesh->SetVertexTexCoords(0, 0.0f, 0.0f, 1);
    mesh->SetVertexTexCoords(1, 1.0f, 0.0f, 1);
    mesh->SetVertexTexCoords(2, 0.0f, 1.0f, 1);
    mesh->SetVertexTexCoords(3, 1.0f, 1.0f, 1);

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

Shader :

#version 450
#extension GL_GOOGLE_include_directive : enable
#extension GL_ARB_separate_shader_objects : enable
#extension GL_EXT_multiview : enable

#include "../../../../../../../../UltraEngine/Templates/Common/Shaders/Base/TextureArrays.glsl"
#include "../../../../../../../../UltraEngine/Templates/Common/Shaders/Base/Materials.glsl"


layout(location = 5 ) in flat uint inMaterialIndex;
layout(location = 2 ) in vec4 inTexCoords;

layout(location = 0) out vec4 color[8];


void main() {
	color[0] = texture( texture2DSampler[ GetMaterialTextureHandle( materials[ inMaterialIndex ] , 0 ) ] , inTexCoords.zw );
}

Files :

Shaders.zip

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...