🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Triplanar rendering for Voxel terrain

Started by
4 comments, last by swiftcoder 3 years ago

Hello, I have an issue with texturing, I am using tri-planar but it's not working for me any suggestion?

a working sample integrated with Luna frank here sample

​https://github.com/fido9dido/Dual-Contour

the code for tri-planar in

https://github.com/fido9dido/Dual-Contour/blob/master/TexWaves/Shaders/Default.hlsl

and the Dual Contour is in CreateCubeGrid here​​

https://github.com/fido9dido/Dual-Contour/blob/master/Common/GeometryGenerator.cpp

Advertisement

Can you post a screen shot that demonstrates what about it isn't working?

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

This is the result I get from this code, only one of the 3 axes is rendered the rest are stretched as you can see,

This is the result I get right now

I expect the result to be somewhere in between these two images, the image below has terrible colors but the terrain is somewhat wrapped, yet still it's not the best result

I expect something similar to this with better lighting/ color

The most likely issues is that your normals are a bit off. Can you output those to verify they are correct? A simple NdotL lighting shader (untextured) would do the trick.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Yeah thanks, you are right, I was told it's a normal issue, the way normal was calculated was through an approximation of tangent, I changed that to the cross product of edges, here's how it looks before and after, Now I am looking for a way to calculate the weighted normals per vertex.

On the left Normal calculated using Approximating Normals for Marching Cubes method, on the right the cross product of edges
This is the sum of normals at a certain vertex

fido9dido said:
Now I am looking for a way to calculate the weighted normals per vertex.

What you are doing there looks fine - sum and normalise is the usual method. The cross-products at each edge are already weighted by triangle area if you don't normalise them before summing.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

This topic is closed to new replies.

Advertisement