📈 GH Trending Explorer 🎲 Surprise me

← all repos

sebasvcx / ViewportStencil

git clone https://github.com/sebasvcx/ViewportStencil.git v1.0.1 · 20d ago

Render models inside surfaces with ViewportFrames: ground cracks, holes and portals, without cutting anything.

—
stars, 24h
—
stars, 7 days
+80
stars, 30 days · #2,819
80
★ total
8
forks · 0 open issues

Star history starts 2026-10-20; the chart appears after the second daily snapshot.

LanguageLua
LicenseMIT
Created2026-09-29 (21d ago)
Last push20d ago
Watchers0
OwnerUser

GitHub topics

Links

README excerpt
# ViewportStencil
ViewportStencil renders a model *inside* a surface in Roblox: ground cracks, holes, craters, portals or openings in
walls. No geometry is cut or destroyed. A ViewportFrame drawn on the surface displays the model with a perspective
projection that matches the player's camera, so the surface appears to open into the model from any viewing angle.
https://github.com/user-attachments/assets/327176e7-4088-4e5a-ae76-2bd95e788072
## Contents
- How it works
- Installation
- Quick start
- API reference
- Making a model
- Lighting
- Performance
- Limitations
- Example
- Development
- Credits
- License
## How it works
ViewportStencil combines two existing techniques:
- **Off-axis projection**, from rbx-viewport-window by EgoMoose.
 An invisible part carries a SurfaceGui with a ViewportFrame. Every frame, the ViewportFrame's camera is placed at
 the player's camera position and given an off-axis projection, so the image lines up with the surface and behaves
 like a window rather than a flat picture.
- **ViewportFrame masking**, described in
 this DevForum post. Inside a ViewportFrame, faces
 whose vertex alpha has been erased are not drawn, but they still occlude the geometry behind them. Each model
 includes a flat mask plane with erased alpha around its opening. Where the mask is, the ViewportFrame is
 transparent and the real surface shows through; the rest of the model is only visible through the opening.
Because the mask is part of the mesh, every model defines its own shape. See Making a model.
## Installation
You don't need a GitHub account to download ViewportStencil. Choose one of the options below.
### Option 1: Model file (recommended)
1. Open the latest release.
2. Under **Assets**, click `ViewportStencil.rbxm` to download it.
3. In Roblox Studio, open the **Explorer** window, right-click **ReplicatedStorage** and choose
 **Insert from File...**. Select the downloaded `ViewportStencil.rbxm`.
4. Check that `ReplicatedStorage` now contains a ModuleScript named `ViewportStencil`, with the child modules
 `Projection`, `Renderer`, `RigPool`, `Stencil`, `Types` and `Utils`.
The module has to be somewhere LocalScripts can reach. `ReplicatedStorage` is the standard location.
### Option 2: Wally
If your project uses Rojo and Wally, add the dependency to your
`wally.toml`:
 [code] 
Then run `wally install`.
### Option 3: Demo place
To try it without setting anything up, download `ViewportStencil-Demo.rbxl` from the
latest release, open it in Studio and press **Play**.
See Example.
### Updating
The version is written at the top of the `ViewportStencil` ModuleScript. To update, delete the old module and insert
the new `ViewportStencil.rbxm` from the latest release, or change the version in your `wally.toml`. Check the
release notes for changes that may affect your code.
## Quick start
ViewportStencil runs on the client only, so it must be required from a LocalScript (for example, one in
`StarterPlayerScripts`).
 [code] 
Two things to keep in