You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Precalculate this in C++ whenever terrain_size is changed and pass in the uniform: terrain_size_inv rather than in the shader. WIll save millions of divides per second.
Maybe also make an FMA macro that uses fma or *+ depending on compatibility or not
3. Lookup region only once per vertex. Move into vertex() and save as a varrying for the colormap in fragment. - Looks bad on lower LODs when using this to calculate pixel data as the vertices are far apart.
6. Replace 16x16 Region map with an array. No need for a texture lookup
7. Replace 512x512 region blend map w/ a zoomed UV lookup of the region map, or a mathematical version from an array.
8. Since we're blending 4 adjacent vertices, move lookups to vertex() and weight in fragment. - Doesn't look good on lower LODs as the vertices are farther apart, but see redesign below.
10. Instead of sampling base/overlay texture lookups for each vertex, bilinear interpolate the UV for the texture lookup and sample albedo/normal once.
11. light() is wasteful for mobile according to lfxu. Rewrite it to do only what is needed.
Consider looking up height, region, control, color all in vertex. Then with a large mesh, interpolate all in fragment. No lods, or very distant. No fragment lookups. Reducing memory usage (and query) is best optimization.
Use triangle strips instead of triangles. And render terrain vertices without meshes.
Performance
terrain_size_inv
rather than in the shader. WIll save millions of divides per second.Terrain3D/src/terrain_material.cpp
Line 98 in 0bb046e
https://docs.godotengine.org/en/latest/tutorials/shaders/shader_reference/shading_language.html
e.g.
https://github.com/outobugi/GDExtensionTerrain/blob/0bb046eb2e0da0c137e91f74215f574f353f95fb/src/terrain_material.cpp#L73
https://github.com/outobugi/GDExtensionTerrain/blob/0bb046eb2e0da0c137e91f74215f574f353f95fb/src/terrain_material.cpp#L80
https://github.com/outobugi/GDExtensionTerrain/blob/0bb046eb2e0da0c137e91f74215f574f353f95fb/src/terrain_material.cpp#L141
Maybe also make an FMA macro that uses fma or
*+
depending on compatibility or notLookup region only once per vertex. Move into vertex() and save as a varrying for the colormap in fragment.- Looks bad on lower LODs when using this to calculate pixel data as the vertices are far apart.texturegrad
withtexture
, if we don't need it for 3D Projection. See Fragment & Texture Normals are wrong #169 update 2 and Fragment & Texture Normals are wrong #169 (comment)https://community.khronos.org/t/if-statements-in-shaders-confused-by-results/73518/15
Since we're blending 4 adjacent vertices, move lookups to vertex() and weight in fragment.- Doesn't look good on lower LODs as the vertices are farther apart, but see redesign below.Functional
Firefly artifacts along seams between perfectly aligned meshes godotengine/godot#35067 (comment)
Sometimes I've had the need for antialiasing and have typically faded out (vertex grid, macrovariation) instead of aliasing. Perhaps anti-aliasing is better.
https://stackoverflow.com/questions/20204561/advanced-moir%C3%A9-a-pattern-reduction-in-hlsl-glsl-procedural-textures-shader-a
https://www.yaldex.com/open-gl/ch17lev1sec4.html#ch17fig04
https://bgolus.medium.com/normal-mapping-for-a-triplanar-shader-10bf39dca05a
Redesign
The text was updated successfully, but these errors were encountered: