#Scissoring a Render Target into pieces

1 messages · Page 1 of 1 (latest)

trim berry
#

Just gonna put this in a thread

wooden oasis
#

👍

trim berry
#

Okay, but why don't you want to use the system designed specifically for taking high resolution screenshots?

#

"Because I'm after the challenge of making my own without relying on existing systems" is a legitimate answer, if that's what it is

wooden oasis
#

you mean the poster console command?

trim berry
#

It renders only part of the view you define so you can render the larger view in smaller sections and stitch them together

#

This image being an example of that

wooden oasis
#

my actual reason is im making panoramic screenshots
It'll render segments of a bunch of screenshots to the rendertarget, each angled differently, then save that.

I was going to use offcenter for that but was having issues. dont know how to describe it but I couldnt get the edges to go where i wanted, I can try again tho. was giving me a headache earlier so i switched to scissorrect but that seems to be an issue now too lol

trim berry
#

On the one hand, scissorrect should work with Render Targets as far as I know

#

On the other hand, it's actively the wrong tool for this job

wooden oasis
#

true lol

trim berry
#

Let me recommend playing around with the options for render.RenderView without the panoramic logic or render targets or any of that.

Just try messing with the settings and get a "feel" for how they work. Then, when you understand it more intuitively, start applying that understanding to your problem specifically

#

It might help with the frustration you're experiencing when you try to do BOTH learning and applying at the same time

wooden oasis
#

Ok, so heres the issue im having, I think @trim berry

Here I'm just using RenderView to draw to the screen (in PostRenderVGUI).
The *only *difference between these two screenshots is that I changed the w value in the ViewData from 600 to 300.
The box is cut in half/squished..... but everything else is also getting... shifted? I guess?
That doesn't seem right, I almost wanna say this is a bug with RenderView but I don't have that much experience with it

#
hook.Add( "PostRenderVGUI", "testingRenderView", function()
    -- get relevant convars
    local drawVM = cvarDrawViewModel:GetBool()
    local drawFOV = cvarFov:GetInt()
    
    local screenSize = 600 -- the height of our screen (and width, assuming each render is square)
    --local segmentDegrees = math.min( 30, drawFOV ) -- how many degrees each segment should cover; it cant be less than the FOV
    local segmentWidth = 200 -- how many pixels will cover the chosen degrees
    
    local cropStart = (screenSize/2) - (segmentWidth/2)
    
    local function DrawSegment( rotation )
        
        --render.SetScissorRect( 0, 0, 500, 500, true )
        --print( cropStart, 0, cropStart + segmentWidth, screenSize )
        
        -- Render the scene
        local ViewData = {
            fov = drawFOV,
            drawviewmodel = drawVM,
            
            x = 10, --cropStart
            y = 10,
            
            w = screenSize/2,
            h = screenSize,
            
            aspect = 1, -- keep this 1 so our fov works as intended
            
            offcenter = {
                left = 0,
                right = screenSize,
                top = 0,
                bottom = screenSize,
            },
        }
        render.RenderView( ViewData )
        
        --surface.SetDrawColor(255,255,255,255)
        --surface.DrawRect(0, 0, screenSize, screenSize)--debug
        
        --reset to default
        --render.SetScissorRect( 0, 0, 0, 0, false )
    end

    
    --render.PushRenderTarget( OutputRT )
    --cam.Start2D()

        -- Make models look nice
        SetGlobalLOD( 0 )

        -- Clear
        --render.Clear( 0, 0, 0, 0, true, true )

        DrawSegment( 0 )

        -- Restore models LODs
        SetGlobalLOD( -1 )

    --cam.End2D()
    --render.PopRenderTarget()
end )

the full hook code

trim berry
#
hook.Add( "PostRenderVGUI", "testingRenderView", function()
    
    local xPan = math.sin( CurTime() ) * 1000
    local yPan = math.cos( CurTime() ) * 250
    
    local viewSize = 1000

    local ViewData = {
        fov = 90,
        drawviewmodel = false,
        x = 100, y = 100,
        w = viewSize, h = viewSize,
        aspect = 1,
        offcenter = {
            left = 0 + xPan,
            right = viewSize + xPan,
            top = 0 + yPan,
            bottom = viewSize + yPan,
        },
    }
    render.RenderView( ViewData )
end )
#

Or, slightly modified to be closer to what it seems like you're looking for:

hook.Add( "PostRenderVGUI", "testingRenderView", function()
    local xPan = math.sin( CurTime() ) * 1000
    local yPan = 0
    
    local viewWidth = 100
    local viewHeight = 1000

    local aspectRatio = viewWidth / viewHeight

    local ViewData = {
        fov = 20,
        drawviewmodel = false,
        x = 100, y = 100,
        w = viewWidth, h = viewHeight,
        aspect = aspectRatio,
        offcenter = {
            left = 0 + xPan,
            right = viewWidth + xPan,
            top = 0 + yPan,
            bottom = viewHeight + yPan,
        },
    }
    render.RenderView( ViewData )
end )
wooden oasis
#

OHH
I think what's been confusing me is whether I should be messing with the w or the offcenter values to make it thinner

trim berry
#

This is what I mean by learning separately