Skip to content
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
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Resources/Scripts/Gui/Client/ChatSayWindow.as
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ namespace spades {
@field = CommandField(Manager, ui.chatHistory);
field.Bounds = AABB2(winX, winY, winW, 30.f);
field.Placeholder = _Tr("Client", "Chat Text");
field.MaxLength = 93;
Copy link
Owner

@yvt yvt Aug 4, 2020

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.

@field.Changed = spades::ui::EventHandler(this.OnFieldChanged);
AddChild(field);
}
Expand Down
15 changes: 15 additions & 0 deletions Resources/Scripts/Gui/Preferences.as
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,19 @@ namespace spades {
_Tr("Preferences", "OFF")},
array<int> = {2, 1, 0});

layouter.AddHeading(_Tr("Preferences", "OpenGL Effects"));
layouter.AddToggleField(_Tr("Preferences", "Outlines"), "cg_outlines");
layouter.AddSliderField(_Tr("Preferences", "Outline Strength"), "cg_outlineStrength", 1, 3, 1,
ConfigNumberFormatter(0, "px"));
layouter.AddToggleField(_Tr("Preferences", "Textures"), "cg_textures");
layouter.AddToggleField(_Tr("Preferences", "Multi-Texture Mode"), "cg_multiTextures");
layouter.AddSliderField(_Tr("Preferences", "Texture Strength"), "cg_textureStrength", 0, 100, 1,
ConfigNumberFormatter(0, "%"));

layouter.AddHeading(_Tr("Preferences", "Spectator Tools"));
layouter.AddToggleField(_Tr("Preferences", "Spectator Player Names"), "dd_specNames");
layouter.AddToggleField(_Tr("Preferences", "Spectator Wallhack"), "dd_specWallhack");

layouter.AddHeading(_Tr("Preferences", "Feedbacks"));
layouter.AddToggleField(_Tr("Preferences", "Chat Notify Sounds"), "cg_chatBeep");
layouter.AddToggleField(_Tr("Preferences", "Hit Indicator"), "cg_hitIndicator");
Expand All @@ -654,6 +667,8 @@ namespace spades {
layouter.AddToggleField(_Tr("Preferences", "Server Alert"), "cg_serverAlert");

layouter.AddHeading(_Tr("Preferences", "Misc"));
layouter.AddSliderField(_Tr("Preferences", "Volume"), "s_volume", 0, 100, 1,
ConfigNumberFormatter(0, "%"));
layouter.AddSliderField(_Tr("Preferences", "Field of View"), "cg_fov", 45, 90, 1,
ConfigNumberFormatter(0, " deg"));
layouter.AddSliderField(_Tr("Preferences", "Minimap size"), "cg_minimapSize", 128, 256,
Expand Down
16 changes: 16 additions & 0 deletions Resources/Shaders/BasicBlockOutlines.fs
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
}

4 changes: 4 additions & 0 deletions Resources/Shaders/BasicBlockOutlines.program
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Shaders/BasicBlockOutlines.fs
Shaders/BasicBlockOutlines.vs
*shadow*
Shaders/Fog.vs
26 changes: 26 additions & 0 deletions Resources/Shaders/BasicBlockOutlines.vs
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;

}

105 changes: 105 additions & 0 deletions Resources/Shaders/BasicBlockPhysTextures.fs
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
}

6 changes: 6 additions & 0 deletions Resources/Shaders/BasicBlockPhysTextures.program
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
102 changes: 102 additions & 0 deletions Resources/Shaders/BasicBlockPhysTextures.vs
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;
}

64 changes: 64 additions & 0 deletions Resources/Shaders/BasicBlockTextures.fs
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
}

4 changes: 4 additions & 0 deletions Resources/Shaders/BasicBlockTextures.program
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Shaders/BasicBlockTextures.fs
Shaders/BasicBlockTextures.vs
*shadow*
Shaders/Fog.vs
Loading