Some crash fixes when playing an animation

This commit is contained in:
KillzXGaming 2019-06-03 20:53:11 -04:00
parent e1431631ad
commit 537da9866b
8 changed files with 11 additions and 12 deletions

Binary file not shown.

View file

@ -183,7 +183,7 @@ namespace Switch_Toolbox.Library
private void AdvanceNextFrame()
{
if (animationTrackBar.CurrentFrame == animationTrackBar.FrameCount)
if (animationTrackBar.CurrentFrame == animationTrackBar.FrameCount - 1)
{
if (IsLooping)
currentFrameUpDown.Value = 0;
@ -192,7 +192,8 @@ namespace Switch_Toolbox.Library
}
else if (!animationTrackBar.Locked)
{
currentFrameUpDown.Value++;
if (currentFrameUpDown.Value < totalFrame.Value)
currentFrameUpDown.Value++;
}
currentFrameUpDown.Refresh();
@ -313,7 +314,6 @@ namespace Switch_Toolbox.Library
float animFrameNum = frameNum;
if (anim is MaterialAnimation)
{
((MaterialAnimation)anim).SetFrame(animFrameNum);
@ -381,8 +381,6 @@ namespace Switch_Toolbox.Library
Dispose();
}
private void AnimationPanel_Load(object sender, EventArgs e)
{
Viewport viewport = LibraryGUI.Instance.GetActiveViewport();

View file

@ -142,7 +142,7 @@ vec3 CalcBumpedNormal(vec3 normal, sampler2D normalMap, VertexAttributes vert, f
float AmbientOcclusionBlend(sampler2D BakeShadowMap, VertexAttributes vert, float ao_density);
vec3 EmissionPass(sampler2D EmissionMap, float emission_intensity, VertexAttributes vert, float texCoordIndex, vec3 emission_color);
vec3 SpecularPass(vec3 I, vec3 normal, int HasSpecularMap, sampler2D SpecularMap, vec3 specular_color, VertexAttributes vert, float texCoordIndex, int UseSpecularColor);
vec3 ReflectionPass(vec3 N, vec3 I, vec4 diffuseMap, float SpecularAmount, float aoBlend, vec3 tintColor, VertexAttributes vert);
vec3 ReflectionPass(vec3 N, vec3 I, vec4 diffuseMap, vec3 Specular, float aoBlend, vec3 tintColor, VertexAttributes vert);
float ParseComponent(int Type, vec4 Texture)
{
@ -271,8 +271,10 @@ void main()
// Render Passes
if (HasEmissionMap == 1 || enable_emission == 1) //Can be without texture map
fragColor.rgb += EmissionPass(EmissionMap, emission_intensity, vert, 0, emission_color);
fragColor.rgb += SpecularPass(I, N, HasSpecularMap, SpecularMap, specular_color, vert, 0, UseSpecularColor);
fragColor.rgb += ReflectionPass(N, I, diffuseMapColor,SpecularAmount, AoPass, tintColor, vert);
vec3 SpecularPassOutput = SpecularPass(I, N, HasSpecularMap, SpecularMap, specular_color, vert, 0, UseSpecularColor);
fragColor.rgb += SpecularPassOutput;
fragColor.rgb += ReflectionPass(N, I, diffuseMapColor,SpecularPassOutput, AoPass, tintColor, vert);
fragColor.rgb *= pickingColor.rgb;

View file

@ -81,16 +81,15 @@ vec3 SphereMapColor(vec3 viewNormal, sampler2D spheremap) {
return texture(spheremap, sphereTexcoord * 0.5 + 0.5).rgb;
}
vec3 ReflectionPass(vec3 N, vec3 I, vec4 diffuseMap, float specularAmount, float aoBlend, vec3 tintColor, VertexAttributes vert) {
vec3 ReflectionPass(vec3 N, vec3 I, vec4 diffuseMap, vec3 Specular, float aoBlend, vec3 tintColor, VertexAttributes vert) {
vec3 reflectionPass = vec3(0);
// cubemap reflection
vec3 R = reflect(I, N);
R.y *= -1.0;
vec3 R = reflect(-I, N);
int maxSpecularLod = 8;
vec3 cubeColor = textureLod(specularIbl, R, maxSpecularLod).rgb;
reflectionPass += cubeColor * specularAmount;
reflectionPass += cubeColor * Specular;
vec3 viewNormal = mat3(sphereMatrix) * normalize(N.xyz);
vec3 sphereMapColor = SphereMapColor(vert.viewNormal, SphereMap);