Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guide on how to texture an object #44

Closed
famecastle opened this issue May 24, 2020 · 13 comments
Closed

Guide on how to texture an object #44

famecastle opened this issue May 24, 2020 · 13 comments

Comments

@famecastle
Copy link

famecastle commented May 24, 2020

This game engine is amazing! Unfortunately, especially to those not so experienced with 3d modelling / game development in general, it's quite hard to understand how to apply textures to the models.

A guide on that would be great. Just two examples which I don't know how to realize:

  • I have a cube entity. The default one. How can I create a cube map texture (so not the same texture for every side of the cube) for it through the official Ursina engine? What does my texture need to look like? What methods do I need to call? Maybe I would like to texture your Minecraft code sample.

  • I have modelled some basic stuff in blender. Let's say it's a low-poly car. I just switched to edit mode, pulled around some corners and then exported to a .obj file. How would I texture that one? Would I have to apply textures in Blender and somehow export them? I'm lost.

Thank you for your great work so far!

@pokepetter
Copy link
Owner

You should look up uv mapping. Here's an explanation: https://www.youtube.com/watch?v=scPSP_U858k

@famecastle
Copy link
Author

famecastle commented May 25, 2020 via email

@pokepetter
Copy link
Owner

The uvs are part of the model, so you don't have to do anything, just set the texture you want (texture='file_name').

The easiest way to make a cube like that would be to replace the model with a custom one that's unwrapped how you want it. While it's possible to use 6 quads and 6 images to make one cube, it a bad idea since it's ~6 times less performant.

If you want to change the uvs in ursina without using a 3d program, you can modify/set model.uvs and then call model.generate() to update it.

@famecastle
Copy link
Author

Thank you for the explanation! I didn't know it was that simple.

@famecastle
Copy link
Author

Again, I've got a question. I've right now used the Blender default cube and scaled it by 0.5 along all axes (because I've seen that it's 2x2x2 by default). I switched to Edit Mode and checked the UV map. It was fine but just for the sake of correctness I pressed "u > UV Unwrap".

I had 6 tiles, so I combined them with ImageMagick into a single quadratic 512x512 cubemap so that it fits the Blender unwrapping.

cubemap2

As you can see in the image, I had to rotate each side by 90 degrees for them to show up properly.

Now it's looking good but not entirely perfect. I can see slim white lines on the edges of my cube - in my game as well as in Blender when applying the cubemap texture.

image

However, I can't see the lines in my cubemap.png . Do you know if I'm doing anything wrong?

@pokepetter
Copy link
Owner

pokepetter commented May 26, 2020

I believe those are uv seams. The common way to solve that is to extend the edges in the texture so there's less white space around the shape.
For pixel graphics you can just disable the bilinear filtering with Texture.default_filtering = None

@CREATOR118
Copy link

why is this so frickin hard

@CREATOR118
Copy link

how do i make my own textures using blender
and i need it to be a png uv map

btw pokepetter if u see this u might know me as
"THE_godof_death" from your discord server :)

@kkhashayar
Copy link

Hi.
Can you please explain how I can use collision!? in 2D mode between two objects, it looks very complicated!
Thanks a lot.

@Borrito0
Copy link

Borrito0 commented Mar 25, 2021

The way I check for collisions is first:

  • adding the box collider to an Entity: your_model=Entity(model='quad',color=color.white,scale=(1,1),position=(0,0),collider='box')
    -then doing the same thing with another object
  • and then checking for a collision in the main loop:
    def update():
    hit_info=your_model.intersects()
    if hit_info.hit:
    #Do whatever you want

@ghost
Copy link

ghost commented Oct 1, 2021

You should look up uv mapping. Here's an explanation: https://www.youtube.com/watch?v=scPSP_U858k

what software do you recommend because i have had no luck in finding any good free ones.

@venaxyt
Copy link

venaxyt commented Nov 28, 2021

Blender is probably the best free one, even it's very hard to use.

@ghost
Copy link

ghost commented Dec 2, 2021

Blender is probably the best free one, even it's very hard to use.

I made that comment a while ago. since then, I have already learned blender. thanks though.

@C0rupted C0rupted mentioned this issue Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants