-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #8 by implementing render groups 32 and 33
Apparently I had support for emission groups for way longer now.
- Loading branch information
Showing
4 changed files
with
106 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Diffuse with specular. Arguably what should have been the default from the | ||
* beginning, but XPS implemented it only recently. It's a copy of DiffuseBump | ||
* that does not use a bump map. | ||
*/ | ||
#version 150 | ||
|
||
in vec4 outColor; | ||
in vec2 outTexCoord; | ||
in vec3 positionWorld; | ||
in vec3 normalWorld; | ||
|
||
out vec4 screenColor; | ||
|
||
uniform sampler2D diffuseTexture; | ||
|
||
struct Light { | ||
vec4 diffuseColor; | ||
vec4 specularColor; | ||
vec4 direction; | ||
}; | ||
|
||
layout(std140) uniform LightData { | ||
vec4 cameraPosition; | ||
vec4 ambientColor; | ||
Light lights[3]; | ||
} lightData; | ||
|
||
uniform RenderParameters { | ||
float bumpSpecularGloss; | ||
float bumpSpecularAmount; | ||
} parameters; | ||
|
||
layout(std140) uniform AlphaTest { | ||
uint mode; // 0 - none, 1 - pass if greater than, 2 - pass if less than. | ||
float reference; | ||
} alphaTest; | ||
|
||
void main() | ||
{ | ||
// Find diffuse texture and do alpha test. | ||
vec4 diffuseTexColor = texture(diffuseTexture, outTexCoord); | ||
if ((alphaTest.mode == 1U && diffuseTexColor.a <= alphaTest.reference) || (alphaTest.mode == 2U && diffuseTexColor.a >= alphaTest.reference)) | ||
discard; | ||
|
||
// Base diffuse color | ||
vec4 diffuseColor = diffuseTexColor * outColor; | ||
|
||
// Direction to camera | ||
vec3 cameraDirection = normalize(lightData.cameraPosition.xyz - positionWorld); | ||
|
||
vec4 color = lightData.ambientColor * diffuseColor; | ||
for (int i = 0; i < 3; i++) | ||
{ | ||
// Diffuse term | ||
float diffuseFactor = max(dot(-normalWorld, lightData.lights[i].direction.xyz), 0); | ||
color += diffuseTexColor * lightData.lights[i].diffuseColor * diffuseFactor; | ||
|
||
// Specular term | ||
vec3 reflectedLightDirection = reflect(lightData.lights[i].direction.xyz, normalWorld); | ||
float specularFactor = pow(max(dot(cameraDirection, reflectedLightDirection), 0), parameters.bumpSpecularGloss) * parameters.bumpSpecularAmount; | ||
color += lightData.lights[i].specularColor * specularFactor; | ||
} | ||
|
||
float alpha = alphaTest.mode == 0U ? 1.0 : diffuseTexColor.a; | ||
screenColor = vec4(color.rgb, alpha); | ||
} |