Jump to content

SetUniform causes "Index out of range"


Dreikblack
 Share

Go to solution Solved by Josh,

Recommended Posts

cam2:SetUniform(1, "Thickness", 4);

 

-- Get the displays
local displays = GetDisplays()

-- Create a window
local window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[1], WINDOW_CENTER | WINDOW_TITLEBAR)

-- Create a world
local world = CreateWorld()

-- Create a framebuffer
local framebuffer = CreateFramebuffer(window)

-- Create a camera
local camera = CreateCamera(world)
camera:SetClearColor(0.125)
camera:SetPosition(0, 0, -2)

-- Create a light
local light = CreateBoxLight(world)
light:SetRotation(45, 35, 0)
light:SetRange(-10, 10)
light:SetColor(2)

-- Create a model
local model = CreateBox(world)
model:SetColor(0, 0, 1)
model:SetRenderLayers(1 + 2)

local cam2 = CreateCamera(world);
cam2:SetClearColor(0, 0, 0, 0);
cam2:SetRenderLayers(2);
cam2:SetFov(camera:GetFov());
cam2:SetMatrix(camera:GetMatrix());
cam2:AddPostEffect(LoadPostEffect("Shaders/Outline.fx"));
cam2:SetUniform(1, "Thickness", 4); -- ERROR HERE
local sz = framebuffer:GetSize();
local texbuffer = CreateTextureBuffer(sz.x, sz.y);
cam2:SetRenderTarget(texbuffer);
-- Display overlay
local sprite = CreateSprite(world, sz.x, sz.y);
local color = Vec4(0, 1, 0, 1);
sprite:SetColor(color);
sprite:SetRenderLayers(4);
local mtl = CreateMaterial();
sprite:SetMaterial(mtl);
mtl:SetTransparent(true);
mtl:SetTexture(texbuffer:GetColorAttachment());
local cam3 = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
cam3:SetClearMode(CLEAR_DEPTH);
cam3:SetRenderLayers(4);
cam3:SetPosition(sz.x * 0.5, sz.y * 0.5, 0);

-- Main loop
while not window:Closed() and not window:KeyDown(KEY_ESCAPE) do
    model:Turn(0, 1, 0)
    world:Update()
    world:Render(framebuffer)
end

 

Link to comment
Share on other sites

  • 2 weeks later...

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...