Jump to content

Skybox in 3.0, a simple example, with shader.


shadmar
 Share

Recommended Posts

Hi

 

Here one way to do a skybox in 3.0 without interfering with editing in the editor:

 

skybox.jpg

 


--Create a camera

camera = Camera:Create()

camera:Move(0,5,-15)

 

--Create skybox

sky = Model:Create()

--just render a plane and project cubemap onto it

local surface = sky:AddSurface()

surface:AddVertex(-0.5,-0.5,0, 0,0,-1)

surface:AddVertex(0.5,-0.5,0, 0,0,-1)

surface:AddVertex(0.5,0.5,0, 0,0,-1)

surface:AddVertex(-0.5,0.5,0, 0,0,-1)

surface:AddTriangle(2,1,0)

surface:AddTriangle(0,3,2)

 

--position in front of camera but far out to near camera clip plane

sky:SetPosition(camera:GetPosition())

sky:Move(0,0,camera:GetRange().y-50)

sky:SetScale(camera:GetRange().y*10)

sky:SetParent(camera)

 

-- and paint it

skymat=Material:Create()

shader=Shader:Load("Shaders/Cubemap/sky.shader")

skymat:SetShader(shader)

skytex=Texture:Load("SkyBox/grimnew.tex")

skymat:SetTexture(skytex)

sky:SetMaterial(skymat)

 

Shader and example texture attached below :

  • Upvote 7

HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB

Link to comment
Share on other sites

Awesome work, as usual, shad! Downloading now! smile.png

Will have a look at it, see how it works, and make a few skyboxes for the asset store. wink.png

  • Upvote 1

 

ZBrush 4R7 64-bit - 3DCoat 4.5 BETA 12 - Fl Studio 12 64Bit - LE 3.2 Indie version - Truespace 7 - Blender 2.71 - iClone 5.51 Pro - iClone 3DXChange 5.51 pipeline - Kontakt 5 - Bryce 7 - UU3D Pro - Substance Designer/Painter - Shadermap 3 - PaintShop Photo Pro X7 - Hexagon - Audacity - Gimp 2.8 - Vue 2015 - Reaktor 5 - Guitar Rig 5 - Bitmap2Material 3

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...