Jump to content

SMAA Camera


Go to solution Solved by Josh,

Recommended Posts

Posted
    -- preset actual de MSAA
    self._msaaPreset = nil

    function self:UpdateMSAA(camera)
        local current = _cmbBoxMSAA:GetSelectedItem() -- 1=OFF, 2=2X, 3=4X, 4=8X
        if current == _msaaLast then return end
        _msaaLast = current

            -- Mapeo UI → muestras válidas para Camera:SetMsaa
        local map = {
                [1] = 0,  -- OFF
                [2] = 2,  -- 2X
                [3] = 4,  -- 4X
                [4] = 8,  -- 8X
                    -- Si algún día agregas más:
                [5] = 16,
                [6] = 32,
            }

        local samples = map[current] or 0
        camera:SetMsaa(samples)
            
        self._msaaPreset = current
    end

SMAA does not make changes in real time, only when I restart the APP. Is it an error or is it an expected behavior?


image.thumb.png.14a972165143302ded0ae3f61cc9371d.png

  • Like 1

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

Posted

Your code must have some error, because this code works correctly:

local game = import("Utilities/Game.lua")
if not game then return end
local camera = CreateCamera(game.world)

local box = CreateBox(game.world)
box:Turn(0,0,34)
box:Move(0,0,2)

while true do

	if game.window:KeyDown(KEY_SPACE) then
		camera:SetMsaa(4)
	else
		camera:SetMsaa(1)
	end
    
    --Update the world
    game.world:Update()
    
	--Update Steamworks (optional)
	Steamworks.Update()
	
    --Garbage collection step
    collectgarbage()
	
    --Render the world to the framebuffer
	local vsync = true
	if istable(game.settings.video) and isboolean(game.settings.video.vsync) then vsync = game.settings.video.vsync end
    game.world:Render(game.framebuffer, vsync)
end

::Exit::

game:SaveSettings()

Steamworks.Shutdown()

 

  • Like 1

Let's build cool stuff and have fun. :)

Posted
17 minutes ago, Josh said:

Your code must have some error, because this code works correctly:

local game = import("Utilities/Game.lua")
if not game then return end
local camera = CreateCamera(game.world)

local box = CreateBox(game.world)
box:Turn(0,0,34)
box:Move(0,0,2)

while true do

	if game.window:KeyDown(KEY_SPACE) then
		camera:SetMsaa(4)
	else
		camera:SetMsaa(1)
	end
    
    --Update the world
    game.world:Update()
    
	--Update Steamworks (optional)
	Steamworks.Update()
	
    --Garbage collection step
    collectgarbage()
	
    --Render the world to the framebuffer
	local vsync = true
	if istable(game.settings.video) and isboolean(game.settings.video.vsync) then vsync = game.settings.video.vsync end
    game.world:Render(game.framebuffer, vsync)
end

::Exit::

game:SaveSettings()

Steamworks.Shutdown()

 

I see you're using 1. I thought the documentation said to start at 0, 2, 4, etc.

Now I understand what's happening. I set it to 0 to disable it, and the effect remains stuck

image.thumb.png.d0dec3e383df4f13bc7869433229ca3a.png

  • Like 1

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

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.

×
×
  • Create New...