-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Anarchid
committed
Sep 30, 2021
1 parent
fee591c
commit 5cf5615
Showing
16 changed files
with
101 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
uniform sampler2D tex0; // unqualified heightfield | ||
uniform sampler2D tex1; // 2d normals | ||
uniform sampler2D tex2; // hard rock texture | ||
uniform sampler2D tex3; // flats texture (tier0) | ||
uniform sampler2D tex4; // beach texture (tier-1) | ||
uniform sampler2D tex5; // mid-altitude flats (tier1, grassland) | ||
uniform sampler2D tex6; // high-altitude flats (tier2) | ||
uniform sampler2D tex7; // hillside texture | ||
uniform sampler2D tex8; // ramp texture | ||
|
||
uniform float minHeight; | ||
uniform float maxHeight; | ||
|
||
// should these be uniforms? | ||
const float hardCliffMax = 1.0; // sharpest bot-blocking cliff | ||
const float hardCliffMin = 0.58778525229; // least sharp bot-blocking cliff | ||
|
||
const float softCliffMax = hardCliffMin; | ||
const float softCliffMin = 0.30901699437; | ||
|
||
|
||
vec2 rotate(vec2 v, float a) { | ||
float s = sin(a); | ||
float c = cos(a); | ||
mat2 m = mat2(c, -s, s, c); | ||
return m * v; | ||
} | ||
|
||
void main() | ||
{ | ||
vec2 coord = vec2(gl_TexCoord[0].s,0.5*gl_TexCoord[0].t); | ||
vec4 norm = texture2D(tex1, coord); | ||
vec2 norm2d = vec2(norm.x, norm.a); | ||
float slope = length(norm2d); | ||
float factor = 0.0; | ||
float height = texture2D(tex0,coord).r; | ||
|
||
// tile somewhat | ||
coord = 8.0*coord; | ||
|
||
// base texture | ||
gl_FragColor = texture2D(tex2,coord); | ||
|
||
// ---- altitude textures ---- | ||
|
||
// admix depths (actually same as beaches atm) | ||
factor = smoothstep(-5.0,-17.0,height); | ||
gl_FragColor = mix(gl_FragColor,texture2D(tex4,coord*8),factor); | ||
|
||
// admix beaches | ||
factor = clamp(0.1*(10.0-abs(height)),0.0,1.0); | ||
gl_FragColor = mix(gl_FragColor,texture2D(tex4,coord*8),factor); | ||
|
||
// admix midlands | ||
factor = smoothstep(50.0,150.0,height) * (1.0-slope); | ||
gl_FragColor = mix(gl_FragColor,texture2D(tex5,coord*3),factor); | ||
|
||
// admix highlands | ||
factor = smoothstep(200.0,300.0,height); | ||
gl_FragColor = mix(gl_FragColor,texture2D(tex6,coord),factor); | ||
|
||
// ---- slope textures ---- | ||
|
||
// admix ramps | ||
factor = 0.25*smoothstep(0.1, softCliffMin, slope); | ||
gl_FragColor = mix(gl_FragColor,texture2D(tex8,coord*2),factor); | ||
|
||
// admix hillsides (replace texture later) | ||
factor = 0.5*smoothstep(softCliffMin, softCliffMax, slope); | ||
gl_FragColor = mix(gl_FragColor,texture2D(tex7,coord*2),factor); | ||
|
||
// admix cliffsides | ||
factor = smoothstep(hardCliffMin, hardCliffMax, slope); | ||
gl_FragColor = mix(gl_FragColor,texture2D(tex3,coord),factor); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.