Skip to content

Commit

Permalink
glsl/vp: reduce diff noise between vertex entity, vertex world and li…
Browse files Browse the repository at this point in the history
…ghtmap code
  • Loading branch information
illwieckz committed Feb 10, 2020
1 parent e06386a commit adb1a90
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 46 deletions.
34 changes: 19 additions & 15 deletions src/engine/renderer/glsl_source/lightMapping_vp.glsl
Expand Up @@ -34,21 +34,23 @@ uniform vec4 u_Color;
OUT(smooth) vec3 var_Position;
OUT(smooth) vec2 var_TexCoords;
OUT(smooth) vec2 var_TexLight;

OUT(smooth) vec3 var_Tangent;
OUT(smooth) vec3 var_Binormal;
OUT(smooth) vec3 var_Normal;

OUT(smooth) vec4 var_Color;

void DeformVertex( inout vec4 pos,
inout vec3 normal,
inout vec2 st,
inout vec4 color,
in float time);
inout vec3 normal,
inout vec2 st,
inout vec4 color,
in float time);

void main()
void main()
{
vec4 position;
localBasis LB;
vec4 position;
vec2 texCoord, lmCoord;
vec4 color;

Expand All @@ -57,24 +59,26 @@ void main()
color = color * u_ColorModulate + u_Color;

DeformVertex( position,
LB.normal,
texCoord.xy,
color,
u_Time);
LB.normal,
texCoord,
color,
u_Time);

// transform vertex position into homogenous clip-space
gl_Position = u_ModelViewProjectionMatrix * position;

// transform diffusemap texcoords
var_TexCoords = (u_TextureMatrix * vec4(texCoord, 0.0, 1.0)).st;

var_TexLight = lmCoord;

// assign vertex Position
var_Position = position.xyz;

var_Normal = LB.normal;
var_Tangent = LB.tangent;
var_Binormal = LB.binormal;

// transform diffusemap texcoords
var_TexCoords = (u_TextureMatrix * vec4(texCoord, 0.0, 1.0)).st;

var_TexLight = lmCoord;

// assign color
var_Color = color;
}
31 changes: 17 additions & 14 deletions src/engine/renderer/glsl_source/vertexLighting_DBS_entity_vp.glsl
Expand Up @@ -30,44 +30,47 @@ uniform float u_Time;

OUT(smooth) vec3 var_Position;
OUT(smooth) vec2 var_TexCoords;
OUT(smooth) vec4 var_Color;

OUT(smooth) vec3 var_Tangent;
OUT(smooth) vec3 var_Binormal;

OUT(smooth) vec3 var_Normal;

OUT(smooth) vec4 var_Color;

void DeformVertex( inout vec4 pos,
inout vec3 normal,
inout vec2 st,
inout vec4 color,
in float time);
inout vec3 normal,
inout vec2 st,
inout vec4 color,
in float time);

void main()
{
vec4 position;
localBasis LB;
vec4 position;
vec2 texCoord, lmCoord;
vec4 color;

VertexFetch( position, LB, color, texCoord, lmCoord);

DeformVertex( position,
LB.normal,
texCoord,
color,
u_Time);
LB.normal,
texCoord,
color,
u_Time);

// transform vertex position into homogenous clip-space
gl_Position = u_ModelViewProjectionMatrix * position;

// transform position into world space
var_Position = (u_ModelMatrix * position).xyz;

var_Tangent.xyz = (u_ModelMatrix * vec4(LB.tangent, 0.0)).xyz;
var_Binormal.xyz = (u_ModelMatrix * vec4(LB.binormal, 0.0)).xyz;
var_Normal.xyz = (u_ModelMatrix * vec4(LB.normal, 0.0)).xyz;
var_Tangent = (u_ModelMatrix * vec4(LB.tangent, 0.0)).xyz;
var_Binormal = (u_ModelMatrix * vec4(LB.binormal, 0.0)).xyz;
var_Normal = (u_ModelMatrix * vec4(LB.normal, 0.0)).xyz;

// transform diffusemap texcoords
var_TexCoords = (u_TextureMatrix * vec4(texCoord, 0.0, 1.0)).st;

// assign color
var_Color = color;
}
33 changes: 16 additions & 17 deletions src/engine/renderer/glsl_source/vertexLighting_DBS_world_vp.glsl
Expand Up @@ -32,23 +32,23 @@ uniform vec4 u_Color;

OUT(smooth) vec3 var_Position;
OUT(smooth) vec2 var_TexCoords;
OUT(smooth) vec4 var_Color;

OUT(smooth) vec3 var_Tangent;
OUT(smooth) vec3 var_Binormal;

OUT(smooth) vec3 var_Normal;

OUT(smooth) vec4 var_Color;

void DeformVertex( inout vec4 pos,
inout vec3 normal,
inout vec2 st,
inout vec4 color,
in float time);
inout vec3 normal,
inout vec2 st,
inout vec4 color,
in float time);

void main()
void main()
{
vec4 position;
localBasis LB;
vec4 position;
vec2 texCoord, lmCoord;
vec4 color;

Expand All @@ -57,25 +57,24 @@ void main()
color = color * u_ColorModulate + u_Color;

DeformVertex( position,
LB.normal,
texCoord,
color,
u_Time);
LB.normal,
texCoord,
color,
u_Time);

// transform vertex position into homogenous clip-space
gl_Position = u_ModelViewProjectionMatrix * position;

// assign vertex Position for light grid sampling
var_Position = position.xyz;

var_Normal = LB.normal;
var_Tangent = LB.tangent;
var_Binormal = LB.binormal;

// transform diffusemap texcoords
var_TexCoords = (u_TextureMatrix * vec4(texCoord, 0.0, 1.0)).st;

// assign color
var_Color = color;

var_Tangent = LB.tangent;
var_Binormal = LB.binormal;

var_Normal = LB.normal;
}

0 comments on commit adb1a90

Please sign in to comment.