بنقرة واحدة
lens-studio-camera-texture
Learn how to programmatically request and manage raw camera textures and crops.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Learn how to programmatically request and manage raw camera textures and crops.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Reference guide for 2D UI and screen-space interaction in Lens Studio — covering ScreenTransform anchors/offsets/size/pivot and coordinate conversions (localPointToScreenPoint, screenPointToLocalPoint, localPointToWorldPoint), ScreenImage (texture, stretch mode, color tint), Text component (content, font, alignment, color, size), ScreenRegionComponent for defining tap/touch areas, TouchComponent with TouchStartEvent/TouchMoveEvent/TouchEndEvent, tap input for phone lenses, LSTween UI animations (colorTo, moveTo on screen elements), multi-swatch color picker pattern, undo stack pattern, and common gotchas. Use this skill whenever a lens needs a 2D UI panel, tap interaction, on-screen buttons, text labels, color pickers, swipeable menus, or undo/redo — covering Drawing, Quiz, TappableQuestion, MemeSticker, MusicVideo, and HighScore examples.
Reference guide for face and body AR tracking in Lens Studio — covering FaceTrackingComponent setup (multi-face, faceIndex), FaceInset and FaceMask effects, 2D and 3D Face Attachments (hat/mouth/left_eye/right_eye anchors), Face Mesh UV texturing, Face Landmarks (68 keypoints), Face Expression weights for mouth-open/eye-blink detection, Eye Tracking component (left/right eye direction), Upper Body Tracking 3D asset (hips/spine/shoulder attachment points), Upper Body Mesh for seamless selfie occlusion, and Face Retouch/Eye Color/Face Liquify/Face Stretch effects. Use this skill for any phone or front-camera lens involving faces, selfie effects, makeup, face masks, 3D head ornaments, body tracking, or expression-driven animations — covering the vast majority of Snapchat lens content.
Learn how to dynamically instantiate prefabs algorithmically in grid or spherical patterns.
Implement proximity-based triggers and smooth tethering behaviors for interactive objects.
Learn how to track image markers and detach the tracked content into World Space in AR.
Reference guide for materials and shaders in Lens Studio — covering runtime material property changes (clone-before-modify, mainPass.baseColor, mainPass.opacity, mainPass.baseTex), blend modes (Normal/Alpha/Add/Screen/Multiply), depth and cull settings (depthTest, depthWrite, twoSided, cullMode), render order, material variants, assigning textures and render targets, reading and writing RenderTarget textures for post-processing, the graph-based Material Editor node system, custom shader graph nodes, and common shader pitfalls. Use this skill for any lens that needs to change material colors or textures at runtime, implement custom visual effects with shaders, set up post-processing render pipelines, chain render targets, or debug material/blend-mode issues — covering MaterialEditor, Drawing, and HairSimulation examples.
| name | lens-studio-camera-texture |
| description | Learn how to programmatically request and manage raw camera textures and crops. |
Lens Studio allows developers to intercept the background camera feed for customized rendering loops or image processing. On mobile phone lenses, this is straightforward, but on Spectacles, you must specifically address the correct camera IDs (e.g. Right_Color) since the device utilizes multi-camera input for rendering and tracking.
Official docs: Spectacles Home
The CameraModule handles raw camera requests.
[!IMPORTANT] Because the Lens Studio Editor cannot simulate dual-camera passthrough, you should use
Default_Colorwhen running in the simulation, andRight_Colorwhen compiling for the actual Spectacles device.
@component
export class CameraFeedIntercept extends BaseScriptComponent {
@input
camModule: CameraModule;
start() {
const isEditor = global.deviceInfoSystem.isEditor();
const camID = isEditor ? CameraModule.CameraId.Default_Color : CameraModule.CameraId.Right_Color;
const camRequest = CameraModule.createCameraRequest();
camRequest.cameraId = camID;
// Optionally downsample the resolution to save performance metrics
// camRequest.imageSmallerDimension = isEditor ? 352 : 756;
// This Texture can now be applied to any material or UI element
const rawCameraTexture = this.camModule.requestCamera(camRequest);
}
}
Once you have retrieved the CameraTexture from the CameraModule, you can inject it directly into a standard Lens Studio Material. Just set the mainPass parameter where a sampler2D is expected (typically baseColor).
@input
targetMaterial: Material;
//...
this.targetMaterial.mainPass.baseColor = rawCameraTexture;
If you are passing camera visual data into a SnapML model or a UI sub-view, you frequently need to crop it. You can supply the camera feed to a CropTextureProvider.
@input
screenCropTexture: Texture;
//...
const camTexControl = rawCameraTexture.control as CameraTextureProvider;
const cropTexControl = this.screenCropTexture.control as CropTextureProvider;
// Inject the live camera into the Crop generator
cropTexControl.inputTexture = rawCameraTexture;
// The screenCropTexture is now a modified subsection of the camera feed!
The script below is extracted from the official CompositeCameraTexture package to demonstrate a robust approach for toggling camera request properties based on the environment (Editor vs Device) for optimal development.
See the reference guide for details.