Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
Remove first version files, Add second functional version files
Browse files Browse the repository at this point in the history
  • Loading branch information
chaojian-zhang committed May 19, 2018
1 parent e384253 commit 5fa658d
Show file tree
Hide file tree
Showing 611 changed files with 17,533 additions and 19,298 deletions.
Binary file removed Debug/DevIL.dll
Binary file not shown.
Binary file added Debug/DreamEditor/Assimp32.dll
Binary file not shown.
Binary file added Debug/DreamEditor/Data/CanvasFrame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Debug/DreamEditor/Data/CharMap.fnt
Binary file not shown.
Binary file added Debug/DreamEditor/Data/CharMap_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Debug/DreamEditor/Data/CharMap_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Debug/DreamEditor/Data/DefaultEnvBase.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Debug/DreamEditor/Data/DefaultMeshTexture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Debug/DreamEditor/Data/DefaultNormalTexture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Debug/DreamEditor/Data/Interface_Chn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Debug/DreamEditor/Data/Interface_Eng.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Debug/DreamEditor/Data/Shaders.program
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#version 430 core

in vec3 color;
out vec4 fcolor;

void main()
{
fcolor = vec4(color.rgb, 1.0);
}
24 changes: 24 additions & 0 deletions Debug/DreamEditor/Data/Shaders/InstancedCirclesVertex.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#version 430 core

layout(location = 0) in vec3 vertPosition;
layout(location = 1) in vec3 shapePosition;
layout(location = 2) in vec3 shapeColor;

layout(location = 3) uniform mat4x4 VP;
layout(location = 4) uniform vec3 highlightColor;
layout(location = 5) uniform unsigned int highlightID;

out vec3 color;

void main()
{
if(highlightID == instanceID)
{
color = highlightColor;
}
else
{
color = shapeColor;
}
gl_Position = VP * vec4(vertPosition + shapePosition, 1);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/* In order to provide the ability to use either a color or a texture, we can either: provide different combinations of shaders, which means provide a bunch of meaningless shaders;
Or provide mask texture as color inputs(i.e. the shader expect both a color and a texture, while when only color is needed we can provide a white texture, when texture is needed we can provide a white color).*/

#version 430 core

// Output
layout (location = 0) out vec4 color;

// Input from vertex shader
in VertexOut
{
vec3 PointLightVector;
vec3 SunLightVector;
vec3 SkyUpDirection;
vec3 View;
vec2 texCoord;
vec4 shadowCoord;
} vertexData;

// Material Properties
layout (location = 5) uniform vec3 skyColor;
layout (location = 17) uniform vec3 groundColor;
layout (location = 6) uniform vec3 sunLightColor;
layout (location = 7) uniform vec3 pointLightColor;

layout (location = 8) uniform vec3 diffuseColor;
layout (location = 9) uniform vec3 specularColor;
layout (location = 10) uniform vec3 emissiveColor;
layout (location = 11) uniform float specularPower;

// Textures
layout(binding = 0) uniform sampler2D diffuseMap;
layout(binding = 1) uniform sampler2D specularMap;
layout(binding = 2) uniform sampler2D emissiveMap;
layout(binding = 3) uniform sampler2D normalMap;
//layout(binding = 4) uniform sampler2DShadow shadowMap;
layout(binding = 4) uniform sampler2D shadowMap;

// Main Function: Do lighing in local tangent space
void main(void)
{
// Normalize the incoming vectors, since they are interpreted
vec3 V = normalize(vertexData.View);
vec3 LP = normalize(vertexData.PointLightVector); // D for Point
vec3 LS = normalize(vertexData.SunLightVector); // S for Sun
vec3 LF = normalize(vertexData.SkyUpDirection); // F for fill

// Read the normal from the normal map and normalize it.
vec3 Normal = normalize(texture(normalMap, vertexData.texCoord).rgb * 2.0 - vec3(1.0));
//vec3 Normal = vec3(0,0,1); // Debug: Unrotated normal direction

// Calculate R locally
vec3 RP = reflect(-LP, Normal);
vec3 RS = reflect(-LS, Normal);

// Compute Environment Light Contribution
// Cosine between normal and direction to upper hemisphere
// 1 - normal is oriented to upper hemisphere
// -1 - normal is oriented to lower hemisphere
float cosNormalLight = dot(Normal, LF);
// Shift from [-1,1] to [0,1] range
float lightInfluence = cosNormalLight * 0.5 + 0.5;
// interpolate colors from upper and lower hemispheres
vec3 fillColor = mix(groundColor, skyColor, lightInfluence);

// Compute the diffuse component for each fragment
vec3 diffuseContribution = texture(diffuseMap, vertexData.texCoord).rgb * diffuseColor;
vec3 diffuse = (max(dot(Normal, LP), 0.0) * diffuseContribution * pointLightColor)
+ (max(dot(Normal, LS), 0.0) * diffuseContribution * sunLightColor); // Multiple or Add pointLightColor?
// Pending making things simpler since currently to create a material is not very intuitive because too many color terms

// Compute the specular component for each fragment
vec3 specularContribution = specularColor;
float specularModule = pow(max(dot(RP, V), 0.0), specularPower * texture(specularMap, vertexData.texCoord).r); // Shininess or roughness: Notice we only use R channel of the map
vec3 specular = specularModule * specularContribution * pointLightColor;
//+specularModule * specularContribution * sunLightColor // Not Used

// Compute the emissive component
vec3 emissiveContribution = texture(emissiveMap, vertexData.texCoord).rgb * emissiveColor;
vec3 emissive = emissiveContribution;

// Write final color to the framebuffer
color = vec4(max(dot(Normal, LS), 0.0) * diffuseContribution * sunLightColor, 1.0);
//@color = vec4(fillColor + diffuse + specular + emissive, 1.0);
//@color = vec4(diffuse, 1.0) * textureProj(shadowMap, vertexData.shadowCoord);
//@float depth = textureProj(shadowMap, vertexData.shadowCoord);
//color = vec4(depth, depth, depth, 1.0f);
//@color = vec4(diffuse* textureProj(shadowMap, vertexData.shadowCoord), 1.0) ;
//@
float visibility = 1.0;
if ( texture( shadowMap, vertexData.shadowCoord.xy ).x < vertexData.shadowCoord.z)
{
visibility = 0.2;
}
//color = vec4(visibility, visibility, visibility, 1.0f);
}

/* There are two ways to sample a DepthMap:
One is to treat it as a normal texture and sample as usual
The other is when Texture Comparison is enabled, we can use textureProj to sample 4x, which can make it smoother but highly texeled
In either way, depth bias is applied using glPolygonOffset, since that is more elegant
*/

//@
/*
float visibility = 1.0;
vec2 poissonDisk[4] = vec2[](
vec2( -0.94201624, -0.39906216 ),
vec2( 0.94558609, -0.76890725 ),
vec2( -0.094184101, -0.92938870 ),
vec2( 0.34495938, 0.29387760 ));
for (int i=0;i<4;i++)
{
if ( texture( shadowMap, vertexData.shadowCoord.xy + poissonDisk[i]/3000.0 ).x < vertexData.shadowCoord.z )
{
visibility-=0.2;
}
}
color = vec4(visibility, visibility, visibility, 1.0f);
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/* In order to provide the ability to use either a color or a texture, we can either: provide different combinations of shaders, which means provide a bunch of meaningless shaders;
Or provide mask texture as color inputs(i.e. the shader expect both a color and a texture, while when only color is needed we can provide a white texture, when texture is needed we can provide a white color).*/

#version 430 core

// Output
layout (location = 0) out vec4 color;

// Input from vertex shader
in VertexOut
{
vec3 Normal;
vec3 PointLightVector;
vec3 DirectionalLightVector;
vec3 View;
} vertexData;

// Material Properties
layout (location = 5) uniform vec3 skyColor;
layout (location = 16) uniform vec3 groundColor;
layout (location = 6) uniform vec3 directionalLightColor;
layout (location = 7) uniform vec3 pointLightColor;

layout (location = 8) uniform vec3 diffuseColor;
layout (location = 9) uniform vec3 specularColor;
layout (location = 10) uniform vec3 emissiveColor;
layout (location = 11) uniform float specularPower;

// Textures
layout(binding = 0) uniform sampler2D diffuseMap;
layout(binding = 1) uniform sampler2D specularMap;
layout(binding = 2) uniform sampler2D emissiveMap;
layout(binding = 3) uniform sampler2D normalMap;
// layout(binding = 4) uniform sampler2D environmentMap;

// Main Function
void main(void)
{
// Normalize the incoming vectors
vec3 N = normalize(vertexData.Normal);
vec3 V = normalize(vertexData.View);
vec3 LP = normalize(vertexData.PointLightVector); // D for Point
vec3 LS = normalize(vertexData.DirectionalLightVector); // S for Sun

// Calculate R locally
vec3 RP = reflect(-LP, N);
vec3 RS = reflect(-LS, N);

// Compute Environment Light Contribution
vec3 skyLightUpDirection = vec3(0.0, 1.0, 0.0);
// cosine between normal and direction to upper hemisphere
// 1 - normal is oriented to upper hemisphere
// -1 - normal is oriented to lower hemisphere
float cosNormalLight = dot(N, skyLightUpDirection);
// Shift from [-1,1] to [0,1] range
float lightInfluence = cosNormalLight * 0.5 + 0.5;
// interpolate colors from upper and lower hemispheres
vec3 fillColor = mix(groundColor, skyColor, lightInfluence);

// Compute the diffuse and specular components for each fragment
vec3 diffuse = max(dot(N, LP), 0.0) * diffuseColor * pointLightColor; // Multiple or Add?
//+ max(dot(N, LS), 0.0) * diffuseColor * directionalLightColor;
vec3 specular = pow(max(dot(RP, V), 0.0), specularPower) * specularColor * pointLightColor;

// Write final color to the framebuffer
color = vec4(fillColor + diffuse + specular + emissiveColor, 1.0);
}
Loading

0 comments on commit 5fa658d

Please sign in to comment.