Hey! I was wondering how I could recreate the reflectance effect on a part with a different skybox than the one being used for the sky.
I want to use EditableImages for this rather than ViewportFrames, nor illusions such as having the real skybox be what you want the part to reflect, and then have an inverted sphere mesh with the texture of the fake skybox on it. The reason being that I’ll be able to do much cooler effects if I use EditableImages, such as interpolating between skyboxes and such than if I use other methods (and I’ll learn some useful math).
The only issue, is that I don’t really know how Roblox draws reflectance on meshes, or even parts. I suspect it takes in the mesh’s vertexdata, the mesh’s CFrame, the camera’s CFrame, and the skybox textures, and then a bunch of crazy math goes on under the hood to generate that cool looking effect we call Reflectance. Hence why I’m asking for help to potentially bridge that gap in knowledge and the math required to make it work.
I’m pretty sure it’s just a scrolling texture. Only way to replicate it is to use a texture/surfacegui and use said crazy math to make it scroll in such a way that it roughly matches the skybox orientation
I’m terrible at math, but after some tinkering, I would definitely use SurfaceGuis with ImageLabels that scroll according to the camera’s LookVector for custom reflectance. You could get really fancy and use ViewportFrames with custom parts to mimic light sources reflecting off of models too.
But my best guess would just be to lerp the SurfaceGui texture’s position based on some wizardry revolving around the camera’s LookVector.
I made a sort of pseudo-script that at least makes the SurfaceGui jitter when the camera moves around lol
local RunSVC = game:GetService("RunService")
local camera = workspace.CurrentCamera
local textureGui = script.Parent
local mirrorTexture = textureGui.MirrorTexture
local function camLookVectorNormal() : Vector3 -- YOUR MATH HERE
return camera.CFrame.Position * camera.CFrame.LookVector * math.random(0, 2)
end
local function newTexturePosition() : UDim2
return UDim2.fromOffset(camLookVectorNormal().X, camLookVectorNormal().Z)
end
RunSVC.RenderStepped:Connect(function()
mirrorTexture.Position = mirrorTexture.Position:Lerp(newTexturePosition(), 0.2)
end)