1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-22 15:06:45 +00:00

Fix the material preview sphere

This commit is contained in:
BlueCube3310
2025-10-26 11:40:30 +01:00
parent 0fdbf050e0
commit 3b16d96d82

View File

@@ -393,7 +393,7 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
int lats = 32;
int lons = 32;
const double lat_step = Math::TAU / lats;
const double lat_step = Math::PI / lats;
const double lon_step = Math::TAU / lons;
real_t radius = 1.0;
@@ -432,7 +432,12 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
normals.push_back(v[m_idx]); \
vertices.push_back(v[m_idx] * radius); \
{ \
Vector2 uv(Math::atan2(v[m_idx].x, v[m_idx].z), Math::atan2(-v[m_idx].y, v[m_idx].z)); \
Vector2 uv; \
if (j >= lons / 2) { \
uv = Vector2(Math::atan2(-v[m_idx].x, -v[m_idx].z), Math::atan2(v[m_idx].y, -v[m_idx].z)); \
} else { \
uv = Vector2(Math::atan2(v[m_idx].x, v[m_idx].z), Math::atan2(-v[m_idx].y, v[m_idx].z)); \
} \
uv /= Math::PI; \
uv *= 4.0; \
uv = uv * 0.5 + Vector2(0.5, 0.5); \