ViewportFrame Release

I’m all for an object like this for organisation purposes! Thing that I might want to suggest tho is the ability to point at any LightingObject instance from within a ViewportFrame, similar to how an Adornee property works, to be able to specify how the lighting should look using common objects, or maybe even the Lighting service itself if Lighting were to extend this object.

In any case this should probably be made into a separate suggestion thread.

1 Like

Unfortunately I’m not allowed to make posts in suggestions, I think it’s because I haven’t made any new topics yet since I’m still trying to grasp how the devforum works.

Also if you enlarge the image you will see that there is an Adornee for any LightingObject (also yeah, it’ll probably just be that you can insert multiple Lightings vs a unique object for it)

(The only reason I thought of making them separate objects was because of the new “Future is Bright” which I believe shouldn’t really be used for ViewportFrames since like previously stated, weren’t really intended for massive HD projects.)

1 Like

useful for gfx! gonna give it a spin later

1 Like

Are there any plans for allowing the rendition of the neon material and/or particles?

4 Likes

Viewport frames are pretty cool! I’ve been using them instead to replace images of models. But I’ve just found a bug when a model in a viewport frame has surface guis on it. When i put the model in a viewport frame, the surfaceguis on the model make a strange rendering artifact in game.
Model in workspace:
image

Model in viewport frame:
image

And when i try to select something a frame that is in the surfacegui, it does this:
image
You can even see it in game!
Now it is easy to fix, (just remove the surface gui for the model in the viewport frame) but i think it still should be mentioned… (Also, I would post this in engine bugs, but i’m a new user so i can’t post there and imo this is the best thread to post this on since it’s on viewport frames.)

3 Likes

In the future, you can ask make a thread in #bulletin-board and Lead Top Contributor to move it for you to the right place.

2 Likes

Ah thank you! I had that category muted for me so i didn’t see it. ;p

1 Like

Have you heard of the glass material bug with transparency? You can replicate that effect with that as well, but it’s a matter of preference. I think the glass alternative looks better but it’s also going to be patched according to Roblox, so.

I don’t believe that’s a bug, but just something due to the way SurfaceGuis and BillboardGuis function when in PlayerGui

I have recently noticed an issue with Viewport Frames, It will not set the ViewportSize property of a Camera.

This is especially annoying since you are unable to use WorldToScreenPoint or WorldToViewportPoint as it will always return 0

That’s because multiple ViewportFrames can use the same camera. Since ViewportFrames can have different sizes, there’s no way to decide which size to use.

Is there a way to work around this?

I am using this as a Minimap and I am wanting to be able to mark where people are on the map.

You’re going to have to calculate the positions yourself. Sorry if I can’t tell you how exactly, since I don’t how to, either.

I will probably just end up making a 3D Marker for players in the minimap to save time

Have you tried the AbsoluteSize of a ViewportFrame?

1 Like

Even with me knowing the AbsoluteSize, that would not allow the function WorldtoScreenPoint to work.

1 Like

Here’s some code from a module I wrote, which was borrowed from another module by someone else:

local function pointToScreenSpace(cframe, fieldOfView, point, viewportSize)
	-- borrowed from https://devforum.roblox.com/t/3d-gui-module/5183 ( http://www.roblox.com/Roblox-3D-GUI-Module-item?id=159576724 )
	-- used for transforming points from GetCameraParams into a size
	-- no need to rewrite what's already written!
	local screenSize = viewportSize
	local relative = cframe:pointToObjectSpace(point)
	local ratio = screenSize.x/screenSize.y
	local yFactor = math.tan(math.rad(fieldOfView/2))
	local xFactor = ratio*yFactor
	local y = (relative.y/relative.z) / yFactor
	local x = (relative.x/relative.z) / -xFactor
	return Vector2.new(screenSize.x*(0.5 + 0.5*x), screenSize.y*(0.5 + 0.5*y))
end
5 Likes

I have created a function that will allow you to mimic the function WorldToScreenPoint in a ViewportFrame

    ScreenSpace.ViewportAspectRatio = function(viewport)
	return viewport.AbsoluteSize.X / viewport.AbsoluteSize.Y
end

ScreenSpace.ViewportWorldToScreen = function(viewport,at)
	local point = viewport.CurrentCamera.CoordinateFrame:pointToObjectSpace(at)
	local aspectRatio = ScreenSpace.ViewportAspectRatio(viewport)
	local hfactor = math.tan(math.rad(viewport.CurrentCamera.FieldOfView) / 2)
	local wfactor = aspectRatio * hfactor
	local x = point.x / point.z / -wfactor
	local y = point.y / point.z / hfactor
	return Vector2.new(viewport.AbsoluteSize.X * (0.5 + 0.5 * x), viewport.AbsoluteSize.Y * (0.5 + 0.5 *y)), point.z
end
6 Likes

Thanks for this, I haven’t tested my code so I’m glad I can have something to fall back on!

You could do it with camera CFrame trickery.

It’d be neat to see but impractical.