-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move lightdirection calculation to CPU.
- Loading branch information
Showing
6 changed files
with
38 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,38 @@ | ||
#define SPECULAR | ||
#define GAMMA_CORRECT | ||
#import "DMonkey/Shaders/DM_Light.glsllib" | ||
uniform vec4 m_Color; | ||
uniform float m_LightIntensity; | ||
uniform vec3 m_LightDir; | ||
uniform vec3 m_ViewLightDir; | ||
|
||
const vec3 lightDirection = vec3(0.1, 0.3, 0.0); | ||
const float GAMMA = 2.2; | ||
|
||
vec3 FilmicMain(vec3 texColor){ | ||
float range = 0.2; | ||
texColor *= range; | ||
vec3 x = max(vec3(0.0),texColor-0.004); // Filmic Curve | ||
vec3 retColor = (x*(6.2*x+0.5))/(x*(6.2*x+1.7)+0.06); | ||
return retColor; | ||
} | ||
void main() { | ||
dm_decode(); | ||
|
||
vec3 albedo = GBuffer.albedo; | ||
#ifdef GAMMA_CORRECT | ||
albedo = gamma(GBuffer.albedo, GAMMA); | ||
#endif | ||
|
||
|
||
vec3 lightDir = normalize((g_ViewMatrix * vec4(m_LightDir, 0.0)).xyz); | ||
//lightDir = normalize(m_LightDir); | ||
vec3 albedo = gamma(GBuffer.albedo, GAMMA); | ||
|
||
Light light = Light(vec4(gamma(m_Color.rgb, GAMMA), 0.0), vec3(0.0), lightDir); | ||
Light light = Light(vec4(gamma(m_Color.rgb, GAMMA), 0.0), vec3(0.0), m_ViewLightDir); | ||
vec4 color = ComputeLighting(light); | ||
|
||
color += vec4(0.05, 0.05, 0.1, 0.0); | ||
|
||
gl_FragColor.rgb = albedo * color.rgb; | ||
gl_FragColor.rgb = albedo * color.rgb * 1.5; | ||
|
||
//gl_FragColor.rgb = FilmicMain(gl_FragColor.rgb); | ||
#ifdef GAMMA_CORRECT | ||
gl_FragColor.rgb = gamma(gl_FragColor.rgb, 1.0 / GAMMA); | ||
#endif | ||
} | ||
|
17 changes: 0 additions & 17 deletions
17
assets/Materials/Generated/test_object-test_object_geom_0.j3m
This file was deleted.
Oops, something went wrong.
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