-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #335 from guycalledfrank/matrefactor4
Material system refactor 2
- Loading branch information
Showing
14 changed files
with
172 additions
and
62 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,9 +1,9 @@ | ||
uniform sampler2D texture_normalMap; | ||
uniform float material_bumpMapFactor; | ||
uniform float material_bumpiness; | ||
void getNormal(inout psInternalData data) { | ||
vec3 normalMap = unpackNormal(texture2D(texture_normalMap, $UV)); | ||
data.normalMap = normalMap; | ||
normalMap = normalize(mix(vec3(0.0, 0.0, 1.0), normalMap, material_bumpMapFactor)); | ||
normalMap = normalize(mix(vec3(0.0, 0.0, 1.0), normalMap, material_bumpiness)); | ||
data.normalW = data.TBN * normalMap; | ||
} | ||
|
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,9 +1,9 @@ | ||
uniform sampler2D texture_normalMap; | ||
uniform float material_bumpMapFactor; | ||
uniform float material_bumpiness; | ||
void getNormal(inout psInternalData data) { | ||
vec3 normalMap = unpackNormal(texture2D(texture_normalMap, $UV)); | ||
data.normalMap = normalMap; | ||
normalMap = mix(vec3(0.0, 0.0, 1.0), normalMap, material_bumpMapFactor); | ||
normalMap = mix(vec3(0.0, 0.0, 1.0), normalMap, material_bumpiness); | ||
data.normalW = normalize(data.TBN * normalMap); | ||
} | ||
|
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,7 +1,7 @@ | ||
uniform samplerCube texture_cubeMap; | ||
uniform float material_reflectionFactor; | ||
uniform float material_reflectivity; | ||
void addReflection(inout psInternalData data) { | ||
vec3 lookupVec = fixSeams(cubeMapProject(data.reflDirW)); | ||
lookupVec.x *= -1.0; | ||
data.reflection += vec4($textureCubeSAMPLE(texture_cubeMap, lookupVec).rgb, material_reflectionFactor); | ||
data.reflection += vec4($textureCubeSAMPLE(texture_cubeMap, lookupVec).rgb, material_reflectivity); | ||
} |
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
uniform mat4 matrix_view; | ||
uniform sampler2D texture_sphereMap; | ||
uniform float material_reflectionFactor; | ||
uniform float material_reflectivity; | ||
void addReflection(inout psInternalData data) { | ||
|
||
vec3 reflDirV = (mat3(matrix_view) * data.reflDirW).xyz; | ||
|
||
float m = 2.0 * sqrt( dot(reflDirV.xy, reflDirV.xy) + (reflDirV.z+1.0)*(reflDirV.z+1.0) ); | ||
vec2 sphereMapUv = reflDirV.xy / m + 0.5; | ||
|
||
data.reflection += vec4($texture2DSAMPLE(texture_sphereMap, sphereMapUv).rgb, material_reflectionFactor); | ||
data.reflection += vec4($texture2DSAMPLE(texture_sphereMap, sphereMapUv).rgb, material_reflectivity); | ||
} | ||
|
||
|
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,10 +1,10 @@ | ||
uniform sampler2D texture_sphereMap; | ||
uniform float material_reflectionFactor; | ||
uniform float material_reflectivity; | ||
void addReflection(inout psInternalData data) { | ||
|
||
vec3 reflDirV = vNormalV; | ||
|
||
vec2 sphereMapUv = reflDirV.xy * 0.5 + 0.5; | ||
data.reflection += vec4($texture2DSAMPLE(texture_sphereMap, sphereMapUv).rgb, material_reflectionFactor); | ||
data.reflection += vec4($texture2DSAMPLE(texture_sphereMap, sphereMapUv).rgb, material_reflectivity); | ||
} | ||
|
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,6 +1,6 @@ | ||
float antiAliasGlossiness(inout psInternalData data, float power) { | ||
float rlen = 1.0 / saturate(length(data.normalMap)); | ||
float toksvig = 1.0 / (1.0 + power * (rlen - 1.0)); | ||
return power * mix(1.0, toksvig, material_bumpMapFactor); | ||
return power * mix(1.0, toksvig, material_bumpiness); | ||
} | ||
|
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
Oops, something went wrong.