diff options
author | Cosmic Linden <cosmic@lindenlab.com> | 2024-07-11 15:54:24 -0700 |
---|---|---|
committer | Cosmic Linden <cosmic@lindenlab.com> | 2024-08-06 16:28:47 -0700 |
commit | 6aa9110b2ae346da1a396500cae1b41e8e2d5b75 (patch) | |
tree | 93c83eb1a2c515feef3e00c349f33e16e06d56d2 /indra/newview/llvosurfacepatch.cpp | |
parent | ae2ff22542a5882616778ffab50612f8ad41b71e (diff) |
secondlife/viewer#1883: Local-only PBR terrain paintmap with developer tools
Diffstat (limited to 'indra/newview/llvosurfacepatch.cpp')
-rw-r--r-- | indra/newview/llvosurfacepatch.cpp | 74 |
1 files changed, 32 insertions, 42 deletions
diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp index 471174cf5d..b76717e660 100644 --- a/indra/newview/llvosurfacepatch.cpp +++ b/indra/newview/llvosurfacepatch.cpp @@ -245,7 +245,6 @@ bool LLVOSurfacePatch::updateLOD() void LLVOSurfacePatch::getTerrainGeometry(LLStrider<LLVector3> &verticesp, LLStrider<LLVector3> &normalsp, - LLStrider<LLVector2> &texCoords0p, LLStrider<LLVector2> &texCoords1p, LLStrider<U16> &indicesp) { @@ -260,21 +259,18 @@ void LLVOSurfacePatch::getTerrainGeometry(LLStrider<LLVector3> &verticesp, updateMainGeometry(facep, verticesp, normalsp, - texCoords0p, texCoords1p, indicesp, index_offset); updateNorthGeometry(facep, verticesp, normalsp, - texCoords0p, texCoords1p, indicesp, index_offset); updateEastGeometry(facep, verticesp, normalsp, - texCoords0p, texCoords1p, indicesp, index_offset); @@ -283,7 +279,6 @@ void LLVOSurfacePatch::getTerrainGeometry(LLStrider<LLVector3> &verticesp, void LLVOSurfacePatch::updateMainGeometry(LLFace *facep, LLStrider<LLVector3> &verticesp, LLStrider<LLVector3> &normalsp, - LLStrider<LLVector2> &texCoords0p, LLStrider<LLVector2> &texCoords1p, LLStrider<U16> &indicesp, U32 &index_offset) @@ -322,10 +317,9 @@ void LLVOSurfacePatch::updateMainGeometry(LLFace *facep, { x = i * render_stride; y = j * render_stride; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } } @@ -387,7 +381,6 @@ void LLVOSurfacePatch::updateMainGeometry(LLFace *facep, void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep, LLStrider<LLVector3> &verticesp, LLStrider<LLVector3> &normalsp, - LLStrider<LLVector2> &texCoords0p, LLStrider<LLVector2> &texCoords1p, LLStrider<U16> &indicesp, U32 &index_offset) @@ -421,10 +414,9 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep, x = i * render_stride; y = 16 - render_stride; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } @@ -433,10 +425,9 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep, { x = i * render_stride; y = 16; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } @@ -469,10 +460,9 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep, x = i * render_stride; y = 16 - render_stride; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } @@ -482,10 +472,9 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep, x = i * render_stride; y = 16; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } @@ -525,10 +514,9 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep, x = i * north_stride; y = 16 - render_stride; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } @@ -538,10 +526,9 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep, x = i * north_stride; y = 16; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } @@ -577,7 +564,6 @@ void LLVOSurfacePatch::updateNorthGeometry(LLFace *facep, void LLVOSurfacePatch::updateEastGeometry(LLFace *facep, LLStrider<LLVector3> &verticesp, LLStrider<LLVector3> &normalsp, - LLStrider<LLVector2> &texCoords0p, LLStrider<LLVector2> &texCoords1p, LLStrider<U16> &indicesp, U32 &index_offset) @@ -606,10 +592,9 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep, x = 16 - render_stride; y = i * render_stride; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } @@ -618,10 +603,9 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep, { x = 16; y = i * render_stride; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } @@ -654,10 +638,9 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep, x = 16 - render_stride; y = i * render_stride; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } // Iterate through the east patch's points @@ -666,10 +649,9 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep, x = 16; y = i * render_stride; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } @@ -708,10 +690,9 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep, x = 16 - render_stride; y = i * east_stride; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } // Iterate through the east patch's points @@ -720,10 +701,9 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep, x = 16; y = i * east_stride; - mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords0p.get(), texCoords1p.get()); + mPatchp->eval(x, y, render_stride, verticesp.get(), normalsp.get(), texCoords1p.get()); verticesp++; normalsp++; - texCoords0p++; texCoords1p++; } @@ -992,8 +972,8 @@ void gen_terrain_tangents(U16 strider_vertex_count, LLStrider<LLVector3> &verticesp, LLStrider<LLVector3> &normalsp, LLStrider<LLVector4a> &tangentsp, - LLStrider<LLVector2> &texCoords0p, - LLStrider<U16> &indicesp) + LLStrider<U16> &indicesp, + F32 region_width) { LL_PROFILE_ZONE_SCOPED; @@ -1010,7 +990,10 @@ void gen_terrain_tangents(U16 strider_vertex_count, F32 *n = normalsp[v].mV; normals[v] = LLVector4a(n[0], n[1], n[2], 1.f); tangents[v] = tangentsp[v]; - texcoords[v] = texCoords0p[v]; + + // Calculate texcoords on-the-fly using the terrain positions + texcoords[v].mV[VX] = verticesp[v].mV[VX] / region_width; + texcoords[v].mV[VY] = verticesp[v].mV[VY] / region_width; } for (U32 i = 0; i < strider_index_count; ++i) { @@ -1039,14 +1022,12 @@ void LLTerrainPartition::getGeometry(LLSpatialGroup* group) LLStrider<LLVector3> vertices_start; LLStrider<LLVector3> normals_start; LLStrider<LLVector4a> tangents_start; - LLStrider<LLVector2> texcoords_start; LLStrider<LLVector2> texcoords2_start; LLStrider<U16> indices_start; llassert_always(buffer->getVertexStrider(vertices_start)); llassert_always(buffer->getNormalStrider(normals_start)); llassert_always(buffer->getTangentStrider(tangents_start)); - llassert_always(buffer->getTexCoord0Strider(texcoords_start)); llassert_always(buffer->getTexCoord1Strider(texcoords2_start)); llassert_always(buffer->getIndexStrider(indices_start)); @@ -1056,7 +1037,6 @@ void LLTerrainPartition::getGeometry(LLSpatialGroup* group) { LLStrider<LLVector3> vertices = vertices_start; LLStrider<LLVector3> normals = normals_start; - LLStrider<LLVector2> texcoords = texcoords_start; LLStrider<LLVector2> texcoords2 = texcoords2_start; LLStrider<U16> indices = indices_start; @@ -1069,7 +1049,7 @@ void LLTerrainPartition::getGeometry(LLSpatialGroup* group) facep->setVertexBuffer(buffer); LLVOSurfacePatch* patchp = (LLVOSurfacePatch*) facep->getViewerObject(); - patchp->getTerrainGeometry(vertices, normals, texcoords, texcoords2, indices); + patchp->getTerrainGeometry(vertices, normals, texcoords2, indices); indices_index += facep->getIndicesCount(); index_offset += facep->getGeomCount(); @@ -1082,10 +1062,20 @@ void LLTerrainPartition::getGeometry(LLSpatialGroup* group) LLStrider<LLVector3> vertices = vertices_start; LLStrider<LLVector3> normals = normals_start; LLStrider<LLVector4a> tangents = tangents_start; - LLStrider<LLVector2> texcoords = texcoords_start; LLStrider<U16> indices = indices_start; - gen_terrain_tangents(index_offset, indices_index, vertices, normals, tangents, texcoords, indices); + F32 region_width = 256.0f; + if (mFaceList.empty()) + { + llassert(false); + } + else + { + const LLViewerRegion* regionp = mFaceList[0]->getViewerObject()->getRegion(); + llassert(regionp == mFaceList.back()->getViewerObject()->getRegion()); // Assume this spatial group is confined to one region + region_width = regionp->getWidth(); + } + gen_terrain_tangents(index_offset, indices_index, vertices, normals, tangents, indices, region_width); } buffer->unmapBuffer(); |