-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pubovl (including extras) #905
Draft
Conticop
wants to merge
6
commits into
yvt:master
Choose a base branch
from
Conticop:mod
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
uniform vec3 fogColor; | ||
uniform vec3 outlineColor; | ||
|
||
varying vec3 fogDensity; | ||
|
||
void main() { | ||
|
||
gl_FragColor.rgb = mix(outlineColor, fogColor, fogDensity); | ||
gl_FragColor.a = 1.0; | ||
|
||
#if !LINEAR_FRAMEBUFFER | ||
// gamma correct | ||
gl_FragColor.xyz = sqrt(gl_FragColor.xyz); | ||
#endif | ||
} | ||
|
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,4 @@ | ||
Shaders/BasicBlockOutlines.fs | ||
Shaders/BasicBlockOutlines.vs | ||
*shadow* | ||
Shaders/Fog.vs |
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,26 @@ | ||
uniform mat4 projectionViewMatrix; | ||
uniform mat4 viewMatrix; | ||
uniform vec3 chunkPosition; | ||
uniform vec3 viewOriginVector; | ||
|
||
attribute vec3 positionAttribute; | ||
|
||
varying vec3 fogDensity; | ||
|
||
vec4 FogDensity(float poweredLength); | ||
|
||
void main() { | ||
|
||
vec4 vertexPos = vec4(chunkPosition, 1.); | ||
|
||
vertexPos.xyz += positionAttribute.xyz; | ||
|
||
gl_Position = projectionViewMatrix * vertexPos; | ||
|
||
vec4 viewPos = viewMatrix * vertexPos; | ||
vec2 horzRelativePos = vertexPos.xy - viewOriginVector.xy; | ||
float horzDistance = dot(horzRelativePos, horzRelativePos); | ||
fogDensity = FogDensity(horzDistance).xyz; | ||
|
||
} | ||
|
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,105 @@ | ||
/* | ||
Copyright (c) 2013 yvt | ||
|
||
This file is part of OpenSpades. | ||
|
||
OpenSpades is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
OpenSpades is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with OpenSpades. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
*/ | ||
|
||
|
||
|
||
varying vec4 color; | ||
varying vec2 ambientOcclusionCoord; | ||
varying vec3 fogDensity; | ||
varying vec2 blockTexCoord; | ||
|
||
varying vec3 viewSpaceCoord; | ||
varying vec3 viewSpaceNormal; | ||
uniform vec3 viewSpaceLight; | ||
|
||
varying vec3 reflectionDir; | ||
|
||
uniform sampler2D ambientOcclusionTexture; | ||
uniform sampler2D detailTexture; | ||
uniform vec3 fogColor; | ||
|
||
uniform sampler2D blockTexture; | ||
uniform float blockTextureStrength; | ||
|
||
vec3 EvaluateSunLight(); | ||
vec3 EvaluateAmbientLight(float detailAmbientOcclusion); | ||
vec3 EvaluateDirectionalAmbientLight(float detailAmbientOcclusion, vec3 direction); | ||
//void VisibilityOfSunLight_Model_Debug(); | ||
|
||
float OrenNayar(float sigma, float dotLight, float dotEye); | ||
float CockTorrance(vec3 eyeVec, vec3 lightVec, vec3 normal); | ||
|
||
void main() { | ||
// color is linear | ||
gl_FragColor = vec4(color.xyz, 1.); | ||
|
||
gl_FragColor.rgb = mix(gl_FragColor.rgb, texture2D(blockTexture, blockTexCoord).rgb, blockTextureStrength); | ||
|
||
vec3 shading = vec3(OrenNayar(.8, color.w, | ||
-dot(viewSpaceNormal, normalize(viewSpaceCoord)))); | ||
vec3 sunLight = EvaluateSunLight(); | ||
shading *= sunLight; | ||
|
||
float ao = texture2D(ambientOcclusionTexture, ambientOcclusionCoord).x; | ||
|
||
shading += EvaluateAmbientLight(ao); | ||
|
||
// apply diffuse shading | ||
gl_FragColor.xyz *= shading; | ||
|
||
// fresnel term | ||
// FIXME: use split-sum approximation from UE4 | ||
float fresnel2 = 1. - (-dot(viewSpaceNormal, normalize(viewSpaceCoord))); | ||
float fresnel = fresnel2 * fresnel2; | ||
|
||
fresnel = .03 + fresnel * 0.1; | ||
|
||
// blurred reflections | ||
vec3 reflectWS = normalize(reflectionDir); | ||
vec3 reflection = EvaluateDirectionalAmbientLight(ao, reflectWS); | ||
|
||
gl_FragColor.xyz = mix(gl_FragColor.xyz, reflection, fresnel); | ||
|
||
// specular shading | ||
if(color.w > .1 && dot(sunLight, vec3(1.)) > 0.001){ | ||
vec3 specularColor = sunLight; | ||
gl_FragColor.xyz += specularColor * CockTorrance(-normalize(viewSpaceCoord), | ||
viewSpaceLight, | ||
viewSpaceNormal); | ||
} | ||
|
||
// apply fog | ||
gl_FragColor.xyz = mix(gl_FragColor.xyz, fogColor, fogDensity); | ||
|
||
gl_FragColor.xyz = max(gl_FragColor.xyz, 0.); | ||
|
||
// gamma correct | ||
#if !LINEAR_FRAMEBUFFER | ||
gl_FragColor.xyz = sqrt(gl_FragColor.xyz); | ||
#endif | ||
|
||
#if USE_HDR | ||
// somehow denormal occurs, so detect it here and remove | ||
// (denormal destroys screen) | ||
if(gl_FragColor.xyz != gl_FragColor.xyz) | ||
gl_FragColor.xyz = vec3(0.); | ||
#endif | ||
} | ||
|
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,6 @@ | ||
Shaders/BasicBlockPhysTextures.fs | ||
Shaders/BasicBlockPhysTextures.vs | ||
Shaders/PhysicalModel/OrenNayar.fs | ||
Shaders/PhysicalModel/CookTorrance.fs | ||
*shadow* | ||
Shaders/Fog.vs |
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,102 @@ | ||
/* | ||
Copyright (c) 2013 yvt | ||
|
||
This file is part of OpenSpades. | ||
|
||
OpenSpades is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
OpenSpades is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with OpenSpades. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
*/ | ||
|
||
|
||
|
||
uniform mat4 projectionViewMatrix; | ||
uniform mat4 viewMatrix; | ||
uniform vec3 chunkPosition; | ||
uniform float fogDistance; | ||
uniform vec3 viewOriginVector; | ||
|
||
// --- Vertex attribute --- | ||
// [x, y, z] | ||
attribute vec3 positionAttribute; | ||
|
||
// [ax, ay] | ||
attribute vec2 ambientOcclusionCoordAttribute; | ||
|
||
// [R, G, B, diffuse] | ||
attribute vec4 colorAttribute; | ||
|
||
// [nx, ny, nz] | ||
attribute vec3 normalAttribute; | ||
|
||
// [sx, sy, sz] | ||
attribute vec3 fixedPositionAttribute; | ||
|
||
// [ux, uy] | ||
attribute vec2 blockTexCoordAttribute; | ||
|
||
varying vec2 ambientOcclusionCoord; | ||
varying vec4 color; | ||
varying vec3 fogDensity; | ||
varying vec2 blockTexCoord; | ||
|
||
varying vec3 viewSpaceCoord; | ||
varying vec3 viewSpaceNormal; | ||
|
||
varying vec3 reflectionDir; | ||
|
||
void PrepareForShadowForMap(vec3 vertexCoord, vec3 fixedVertexCoord, vec3 normal); | ||
vec4 FogDensity(float poweredLength); | ||
|
||
void main() { | ||
|
||
blockTexCoord = blockTexCoordAttribute; | ||
|
||
vec4 vertexPos = vec4(chunkPosition, 1.); | ||
|
||
vertexPos.xyz += positionAttribute.xyz; | ||
|
||
gl_Position = projectionViewMatrix * vertexPos; | ||
|
||
color = colorAttribute; | ||
color.xyz *= color.xyz; // linearize | ||
|
||
// lambert reflection | ||
vec3 sunDir = normalize(vec3(0, -1., -1.)); | ||
color.w = dot(sunDir, normalAttribute); | ||
|
||
|
||
// ambient occlusion | ||
ambientOcclusionCoord = (ambientOcclusionCoordAttribute + .5) * (1. / 256.); | ||
|
||
vec4 viewPos = viewMatrix * vertexPos; | ||
vec2 horzRelativePos = vertexPos.xy - viewOriginVector.xy; | ||
float horzDistance = dot(horzRelativePos, horzRelativePos); | ||
fogDensity = FogDensity(horzDistance).xyz; | ||
|
||
vec3 fixedPosition = chunkPosition; | ||
fixedPosition += fixedPositionAttribute * 0.5; | ||
fixedPosition += normalAttribute * 0.1; | ||
|
||
vec3 normal = normalAttribute; | ||
vec3 shadowVertexPos = vertexPos.xyz; | ||
PrepareForShadowForMap(shadowVertexPos, fixedPosition, normal); | ||
|
||
// reflection vector (used for specular lighting) | ||
reflectionDir = reflect(vertexPos.xyz - viewOriginVector, normal); | ||
|
||
// used for diffuse lighting | ||
viewSpaceCoord = viewPos.xyz; | ||
viewSpaceNormal = (viewMatrix * vec4(normal, 0.)).xyz; | ||
} | ||
|
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,64 @@ | ||
/* | ||
Copyright (c) 2013 yvt | ||
|
||
This file is part of OpenSpades. | ||
|
||
OpenSpades is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
OpenSpades is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with OpenSpades. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
*/ | ||
|
||
|
||
|
||
varying vec4 color; | ||
varying vec2 ambientOcclusionCoord; | ||
varying vec2 detailCoord; | ||
varying vec3 fogDensity; | ||
varying vec2 blockTexCoord; | ||
|
||
uniform sampler2D ambientOcclusionTexture; | ||
uniform sampler2D detailTexture; | ||
uniform vec3 fogColor; | ||
|
||
uniform sampler2D blockTexture; | ||
uniform float blockTextureStrength; | ||
|
||
vec3 EvaluateSunLight(); | ||
vec3 EvaluateAmbientLight(float detailAmbientOcclusion); | ||
//void VisibilityOfSunLight_Model_Debug(); | ||
|
||
void main() { | ||
// color is linear | ||
gl_FragColor = vec4(color.xyz, 1.); | ||
|
||
gl_FragColor.rgb = mix(gl_FragColor.rgb, texture2D(blockTexture, blockTexCoord).rgb, blockTextureStrength); | ||
|
||
vec3 shading = vec3(color.w); | ||
shading *= EvaluateSunLight(); | ||
|
||
float ao = texture2D(ambientOcclusionTexture, ambientOcclusionCoord).x; | ||
|
||
shading += EvaluateAmbientLight(ao); | ||
|
||
// apply diffuse shading | ||
gl_FragColor.xyz *= shading; | ||
|
||
// apply fog | ||
gl_FragColor.xyz = mix(gl_FragColor.xyz, fogColor, fogDensity); | ||
|
||
#if !LINEAR_FRAMEBUFFER | ||
// gamma correct | ||
gl_FragColor.xyz = sqrt(gl_FragColor.xyz); | ||
#endif | ||
} | ||
|
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,4 @@ | ||
Shaders/BasicBlockTextures.fs | ||
Shaders/BasicBlockTextures.vs | ||
*shadow* | ||
Shaders/Fog.vs |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Irrelevant to the primary change.