Skip to content

Commit

Permalink
[Shaders] SLSF2_Weapon_Blood support
Browse files Browse the repository at this point in the history
  • Loading branch information
hexabits committed Mar 25, 2015
1 parent a08cc0f commit 61ff987
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
14 changes: 12 additions & 2 deletions res/shaders/sk_effectshader.frag
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ uniform bool useFalloff;
uniform bool vertexColors;
uniform bool vertexAlpha;

uniform bool hasWeaponBlood;

uniform vec4 glowColor;
uniform float glowMult;

Expand Down Expand Up @@ -67,8 +69,16 @@ void main( void )

float alphaMult = glowColor.a * glowColor.a;

color.rgb = baseMap.rgb * C.rgb * glowColor.rgb;
color.a = baseMap.a * C.a * falloff * alphaMult;
color.rgb = baseMap.rgb;
color.a = baseMap.a;

if ( hasWeaponBlood ) {
color.rgb = vec3( 1.0, 0.0, 0.0 ) * baseMap.r;
color.a = baseMap.a * baseMap.g;
}

color.rgb *= C.rgb * glowColor.rgb;
color.a *= C.a * falloff * alphaMult;

if ( greyscaleColor ) {
// Only Red emissive channel is used
Expand Down
1 change: 1 addition & 0 deletions src/gl/glmesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ void Mesh::update( const NifModel * nif, const QModelIndex & index )
bsesp->vertexAlpha = hasSF1( ShaderFlags::SLSF1_Vertex_Alpha );
bsesp->vertexColors = hasSF2( ShaderFlags::SLSF2_Vertex_Colors );

bsesp->hasWeaponBlood = hasSF2( ShaderFlags::SLSF2_Weapon_Blood );

auto uvScale = nif->get<Vector2>( iProp, "UV Scale" );
auto uvOffset = nif->get<Vector2>( iProp, "UV Offset" );
Expand Down
2 changes: 2 additions & 0 deletions src/gl/glproperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,8 @@ class BSEffectShaderProperty final : public BSShaderLightingProperty
bool vertexColors;
bool vertexAlpha;

bool hasWeaponBlood;

struct Falloff
{
float startAngle = 1.0f;
Expand Down
1 change: 1 addition & 0 deletions src/gl/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@ bool Renderer::setupProgram( Program * prog, Mesh * mesh, const PropertyList & p
uni1i( "vertexAlpha", mesh->bsesp->vertexAlpha );
uni1i( "vertexColors", mesh->bsesp->vertexColors );

uni1i( "hasWeaponBlood", mesh->bsesp->hasWeaponBlood );

// Glow params

Expand Down

0 comments on commit 61ff987

Please sign in to comment.