I took a crack at it this morning, is there a particular part of the fragment or vertex shader that is not correctly converted?
It looks like something is not working with just the ground part of the icosphere, when i change the height and radius, it does affect the ground, but like its got incorrect UVs or something
I checked the code, and to my knowledge it is converted correctly, so there must be some aspect that I’m missing.
The class it is based on is this one, so it is a good reference point.
A few things that I’m not sure how they impact the function of the shader is:
I cannot find any references to them in the shader code, but they might be used in one of the imports
If you change the code to output projectedWorldPosition to the outcolor, you can see what it is trying to map.
And I think this could be the problem.
All the ground pixels are black, which when we try to get them from the cube map, they will get the same sand colored pixel.
If we can’t figure it out, I will try to replicate the setup using three, and then we can play around with the shader to debug what the projection should look like.
I also tried out a equirectangular image to rule out that the CubeTexture.CreateFromPrefilteredData was a problem, but it looked the same.
This shader uses several algorithms in ray casting to determine the poisition of the ground and sky spheres.
Since the algorithm calculates the distance from the camera to the ground (or the sky sphere), it will cause an error if the camera position is not updated.
The reason why the ground is a strange color is because the shader has eliminated the illegal positions (below the ground and outside the sphere), so that all illegal positions are reset to (0,1,0).
So the color of all illegal positions is the same color.
@Leon I love the material way and we could put a helper function in sceneHelper for instance to create the mesh and mat for us similar to createDefaultEnvironment ?
About namimg… I am the worst to ask but something like GroundProjectionMaterial sounds descriptive enough ?