g3n / engine

Go 3D Game Engine (http://g3n.rocks)
https://discord.gg/NfaeVr8zDg
BSD 2-Clause "Simplified" License
2.74k stars 292 forks source link

How to create a cubemap? #279

Open tod91 opened 2 years ago

tod91 commented 2 years ago

I see that you support a skybox, but is there an easy way to make a cube map im trying to make a pair of dice.

danaugrs commented 2 years ago

Hi! Yeah, skyboxes in G3N use cube mapping. If you want to texture cubes as dice you need to associate a different material with each cube face. Each cube face is already in a different geometry group to simplify this process. You just need to call mesh.AddGroupMaterial(diceFaceMaterial2, 2) for each cube face. For example, check out how it's done in Gokoban here (where we alter a single cube face) or how we do it for skyboxes here (where we set a different texture+material for each face).

tod91 commented 2 years ago

@danaugrs Hey, thanks for the reply! Works beautifully. The thing i'm concerning myself now

Screen Shot 2022-08-10 at 5 16 18 PM

is that the edges seem very sharp as shown here is there a way to smooth em out i'm planning them to rotate them and have a clean collision detection, meaning as they are now if htey land on their edge the will rotate on some really , for lack of a better word, shady position.

danaugrs commented 2 years ago

You would have to create the 3D model with the edges smoothed out. It's straightforward to do it in Blender e.g. https://www.youtube.com/watch?v=wYBkLrca67Q.