mirror of
https://github.com/raysan5/raylib.git
synced 2026-04-25 08:13:58 -04:00
Make fogColor in the fog tutorial a parameter (#5672)
* uniform fogColor fogColor is now a parameter * use new fog color parameter * convert ambient to Vector4
This commit is contained in:
@ -37,6 +37,7 @@ struct Light {
|
|||||||
uniform Light lights[MAX_LIGHTS];
|
uniform Light lights[MAX_LIGHTS];
|
||||||
uniform vec4 ambient;
|
uniform vec4 ambient;
|
||||||
uniform vec3 viewPos;
|
uniform vec3 viewPos;
|
||||||
|
uniform vec4 fogColor;
|
||||||
uniform float fogDensity;
|
uniform float fogDensity;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
@ -77,10 +78,6 @@ void main()
|
|||||||
// Fog calculation
|
// Fog calculation
|
||||||
float dist = length(viewPos - fragPosition);
|
float dist = length(viewPos - fragPosition);
|
||||||
|
|
||||||
// these could be parameters...
|
|
||||||
const vec4 fogColor = vec4(0.5, 0.5, 0.5, 1.0);
|
|
||||||
//const float fogDensity = 0.16;
|
|
||||||
|
|
||||||
// Exponential fog
|
// Exponential fog
|
||||||
float fogFactor = 1.0/exp((dist*fogDensity)*(dist*fogDensity));
|
float fogFactor = 1.0/exp((dist*fogDensity)*(dist*fogDensity));
|
||||||
|
|
||||||
|
|||||||
@ -72,8 +72,13 @@ int main(void)
|
|||||||
shader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos");
|
shader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos");
|
||||||
|
|
||||||
// Ambient light level
|
// Ambient light level
|
||||||
|
Vector4 ambient = (Vector4){ 0.2f, 0.2f, 0.2f, 1.0f };
|
||||||
int ambientLoc = GetShaderLocation(shader, "ambient");
|
int ambientLoc = GetShaderLocation(shader, "ambient");
|
||||||
SetShaderValue(shader, ambientLoc, (float[4]){ 0.2f, 0.2f, 0.2f, 1.0f }, SHADER_UNIFORM_VEC4);
|
SetShaderValue(shader, ambientLoc, &ambient, SHADER_UNIFORM_VEC4);
|
||||||
|
|
||||||
|
Vector4 fogColor = ColorNormalize(GRAY);
|
||||||
|
int fogColorLoc = GetShaderLocation(shader, "fogColor");
|
||||||
|
SetShaderValue(shader, fogColorLoc, &fogColor, SHADER_UNIFORM_VEC4);
|
||||||
|
|
||||||
float fogDensity = 0.15f;
|
float fogDensity = 0.15f;
|
||||||
int fogDensityLoc = GetShaderLocation(shader, "fogDensity");
|
int fogDensityLoc = GetShaderLocation(shader, "fogDensity");
|
||||||
|
|||||||
Reference in New Issue
Block a user