Intel GPU/OpenGL 2.x planet normals fix

This commit is contained in:
Anuken 2025-10-08 08:45:40 +09:00
parent 576b7f6b6b
commit a0cf5b7265
6 changed files with 22 additions and 7 deletions

View file

@ -29,10 +29,10 @@ void main(){
specular = vec3(1.0 * pow(specularFactor, 40.0)) * albedo;
}
vec3 norc = (u_ambientColor + specular) * (diffuse + vec3(clamp((dot(a_normal, u_lightdir) + 1.0) / 2.0, 0.0, 1.0)));
vec3 norc = (u_ambientColor + specular) * (diffuse + vec3(clamp((dot(a_normal, u_lightdir) + 1.0) / 2.0, 0.0, 1.0)));
float emissive = a_emissive.a * u_emissive * min(pow(max(0.0, (1.0 - norc.r) * 1.2), 3.0), 1.1);
v_col = vec4(mix(a_color.rgb, a_emissive.rgb, emissive), 1.0) * vec4(mix(norc, vec3(1.0), emissive), 1.0);
v_col = vec4(mix(a_color.rgb, a_emissive.rgb, emissive), 1.0) * vec4(mix(norc, vec3(1.0), emissive), 1.0);
gl_Position = u_proj * u_trans * a_position;
}

View file

@ -0,0 +1,13 @@
attribute vec4 a_position;
attribute vec3 a_normal;
uniform mat4 u_proj;
uniform mat4 u_trans;
uniform vec4 u_color;
varying vec4 v_col;
void main(){
v_col = vec4(1.0);
gl_Position = u_proj * u_trans * a_position;
}

View file

@ -33,7 +33,7 @@ public class Shaders{
public static AtmosphereShader atmosphere;
public static ShockwaveShader shockwave;
public static MeshShader mesh;
public static Shader unlit;
public static Shader unlit, unlitWhite;
public static Shader screenspace;
public static void init(){
@ -70,6 +70,7 @@ public class Shaders{
planetGrid = new PlanetGridShader();
atmosphere = new AtmosphereShader();
unlit = new LoadShader("planet", "unlit");
unlitWhite = new LoadShader("planet", "unlitwhite");
screenspace = new LoadShader("screenspace", "screenspace");
//disabled for now...
@ -144,6 +145,7 @@ public class Shaders{
camDir.set(renderer.planets.cam.direction).rotate(Vec3.Y, planet.getRotation());
setUniformf("u_alpha", alpha);
setUniformf("u_emissive", 0f);
setUniformf("u_lightdir", lightDir);
setUniformf("u_ambientColor", ambientColor.r, ambientColor.g, ambientColor.b);
}

View file

@ -275,8 +275,8 @@ public class MeshBuilder{
if(floats.length > 5) floats[5] = emissive;
}else{
floats[3] = normal.x;
floats[4] = normal.x;
floats[5] = normal.x;
floats[4] = normal.y;
floats[5] = normal.z;
floats[6] = color;
if(floats.length > 7) floats[7] = emissive;

View file

@ -160,7 +160,7 @@ public class Planet extends UnlockableContent{
/** Content (usually planet-specific) that is unlocked upon landing here. */
public Seq<UnlockableContent> unlockedOnLand = new Seq<>();
/** Loads the mesh. Clientside only. Defaults to a boring sphere mesh. */
public Prov<GenericMesh> meshLoader = () -> new ShaderSphereMesh(this, Shaders.unlit, 2), cloudMeshLoader = () -> null;
public Prov<GenericMesh> meshLoader = () -> new ShaderSphereMesh(this, Shaders.unlitWhite, 2), cloudMeshLoader = () -> null;
/** Loads the planet grid outline mesh. Clientside only. */
public Prov<Mesh> gridMeshLoader = () -> MeshBuilder.buildPlanetGrid(grid, outlineColor, outlineRad * radius);

View file

@ -52,7 +52,7 @@ public class DesktopLauncher extends ClientLauncher{
height = 700;
//on Windows, Intel drivers might be buggy with OpenGL 3.x, so only use 2.x. See https://github.com/Anuken/Mindustry/issues/11041
if(GpuDetect.hasIntel && (!GpuDetect.hasAMD || !GpuDetect.hasNvidia)){
if(GpuDetect.hasIntel && !GpuDetect.hasAMD && !GpuDetect.hasNvidia){
allowGl30 = false;
coreProfile = false;
glVersions = new int[][]{{2, 1}, {2, 0}};