mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-12-06 02:40:23 -08:00
Intel GPU/OpenGL 2.x planet normals fix
This commit is contained in:
parent
576b7f6b6b
commit
a0cf5b7265
6 changed files with 22 additions and 7 deletions
|
|
@ -29,10 +29,10 @@ void main(){
|
||||||
specular = vec3(1.0 * pow(specularFactor, 40.0)) * albedo;
|
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);
|
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;
|
gl_Position = u_proj * u_trans * a_position;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
13
core/assets/shaders/unlitwhite.vert
Executable file
13
core/assets/shaders/unlitwhite.vert
Executable 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;
|
||||||
|
}
|
||||||
|
|
@ -33,7 +33,7 @@ public class Shaders{
|
||||||
public static AtmosphereShader atmosphere;
|
public static AtmosphereShader atmosphere;
|
||||||
public static ShockwaveShader shockwave;
|
public static ShockwaveShader shockwave;
|
||||||
public static MeshShader mesh;
|
public static MeshShader mesh;
|
||||||
public static Shader unlit;
|
public static Shader unlit, unlitWhite;
|
||||||
public static Shader screenspace;
|
public static Shader screenspace;
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
|
|
@ -70,6 +70,7 @@ public class Shaders{
|
||||||
planetGrid = new PlanetGridShader();
|
planetGrid = new PlanetGridShader();
|
||||||
atmosphere = new AtmosphereShader();
|
atmosphere = new AtmosphereShader();
|
||||||
unlit = new LoadShader("planet", "unlit");
|
unlit = new LoadShader("planet", "unlit");
|
||||||
|
unlitWhite = new LoadShader("planet", "unlitwhite");
|
||||||
screenspace = new LoadShader("screenspace", "screenspace");
|
screenspace = new LoadShader("screenspace", "screenspace");
|
||||||
|
|
||||||
//disabled for now...
|
//disabled for now...
|
||||||
|
|
@ -144,6 +145,7 @@ public class Shaders{
|
||||||
camDir.set(renderer.planets.cam.direction).rotate(Vec3.Y, planet.getRotation());
|
camDir.set(renderer.planets.cam.direction).rotate(Vec3.Y, planet.getRotation());
|
||||||
|
|
||||||
setUniformf("u_alpha", alpha);
|
setUniformf("u_alpha", alpha);
|
||||||
|
setUniformf("u_emissive", 0f);
|
||||||
setUniformf("u_lightdir", lightDir);
|
setUniformf("u_lightdir", lightDir);
|
||||||
setUniformf("u_ambientColor", ambientColor.r, ambientColor.g, ambientColor.b);
|
setUniformf("u_ambientColor", ambientColor.r, ambientColor.g, ambientColor.b);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -275,8 +275,8 @@ public class MeshBuilder{
|
||||||
if(floats.length > 5) floats[5] = emissive;
|
if(floats.length > 5) floats[5] = emissive;
|
||||||
}else{
|
}else{
|
||||||
floats[3] = normal.x;
|
floats[3] = normal.x;
|
||||||
floats[4] = normal.x;
|
floats[4] = normal.y;
|
||||||
floats[5] = normal.x;
|
floats[5] = normal.z;
|
||||||
|
|
||||||
floats[6] = color;
|
floats[6] = color;
|
||||||
if(floats.length > 7) floats[7] = emissive;
|
if(floats.length > 7) floats[7] = emissive;
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ public class Planet extends UnlockableContent{
|
||||||
/** Content (usually planet-specific) that is unlocked upon landing here. */
|
/** Content (usually planet-specific) that is unlocked upon landing here. */
|
||||||
public Seq<UnlockableContent> unlockedOnLand = new Seq<>();
|
public Seq<UnlockableContent> unlockedOnLand = new Seq<>();
|
||||||
/** Loads the mesh. Clientside only. Defaults to a boring sphere mesh. */
|
/** 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. */
|
/** Loads the planet grid outline mesh. Clientside only. */
|
||||||
public Prov<Mesh> gridMeshLoader = () -> MeshBuilder.buildPlanetGrid(grid, outlineColor, outlineRad * radius);
|
public Prov<Mesh> gridMeshLoader = () -> MeshBuilder.buildPlanetGrid(grid, outlineColor, outlineRad * radius);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ public class DesktopLauncher extends ClientLauncher{
|
||||||
height = 700;
|
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
|
//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;
|
allowGl30 = false;
|
||||||
coreProfile = false;
|
coreProfile = false;
|
||||||
glVersions = new int[][]{{2, 1}, {2, 0}};
|
glVersions = new int[][]{{2, 1}, {2, 0}};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue