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 lats = 32;
int lons = 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; const double lon_step = Math::TAU / lons;
real_t radius = 1.0; real_t radius = 1.0;
@@ -428,22 +428,27 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
Vector3(x0 * zr0, z0, y0 * zr0) Vector3(x0 * zr0, z0, y0 * zr0)
}; };
#define ADD_POINT(m_idx) \ #define ADD_POINT(m_idx) \
normals.push_back(v[m_idx]); \ normals.push_back(v[m_idx]); \
vertices.push_back(v[m_idx] * radius); \ 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; \
uv /= Math::PI; \ if (j >= lons / 2) { \
uv *= 4.0; \ uv = Vector2(Math::atan2(-v[m_idx].x, -v[m_idx].z), Math::atan2(v[m_idx].y, -v[m_idx].z)); \
uv = uv * 0.5 + Vector2(0.5, 0.5); \ } else { \
uvs.push_back(uv); \ 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; \
Vector3 t = tt.xform(v[m_idx]); \ uv *= 4.0; \
tangents.push_back(t.x); \ uv = uv * 0.5 + Vector2(0.5, 0.5); \
tangents.push_back(t.y); \ uvs.push_back(uv); \
tangents.push_back(t.z); \ } \
tangents.push_back(1.0); \ { \
Vector3 t = tt.xform(v[m_idx]); \
tangents.push_back(t.x); \
tangents.push_back(t.y); \
tangents.push_back(t.z); \
tangents.push_back(1.0); \
} }
ADD_POINT(0); ADD_POINT(0);