mirror of
https://github.com/Retera/WarsmashModEngine.git
synced 2022-07-31 17:38:59 +02:00
Some fun updates to lighting system
This commit is contained in:
parent
3dc8aff716
commit
faf1cb4b72
@ -1,17 +1,17 @@
|
|||||||
[DataSources]
|
[DataSources]
|
||||||
Count=7
|
Count=7
|
||||||
Type00=MPQ
|
Type00=MPQ
|
||||||
Path00="E:\Games\Warcraft III Patch 1.22\war3.mpq"
|
Path00="D:\Games\Warcraft III Patch 1.22\war3.mpq"
|
||||||
Type01=MPQ
|
Type01=MPQ
|
||||||
Path01="E:\Games\Warcraft III Patch 1.22\War3x.mpq"
|
Path01="D:\Games\Warcraft III Patch 1.22\War3x.mpq"
|
||||||
Type02=MPQ
|
Type02=MPQ
|
||||||
Path02="E:\Games\Warcraft III Patch 1.22\War3xlocal.mpq"
|
Path02="D:\Games\Warcraft III Patch 1.22\War3xlocal.mpq"
|
||||||
Type03=MPQ
|
Type03=MPQ
|
||||||
Path03="E:\Games\Warcraft III Patch 1.22\War3Patch.mpq"
|
Path03="D:\Games\Warcraft III Patch 1.22\War3Patch.mpq"
|
||||||
Type04=Folder
|
Type04=Folder
|
||||||
Path04="..\..\resources"
|
Path04="..\..\resources"
|
||||||
Type05=Folder
|
Type05=Folder
|
||||||
Path05="E:\Backups\Warsmash\Data"
|
Path05="D:\Backups\Warsmash\Data"
|
||||||
Type06=Folder
|
Type06=Folder
|
||||||
Path06="."
|
Path06="."
|
||||||
|
|
||||||
@ -23,4 +23,6 @@ Path06="."
|
|||||||
//FilePath="PlayerPeasants.w3m"
|
//FilePath="PlayerPeasants.w3m"
|
||||||
//FilePath="FireLord.w3x"
|
//FilePath="FireLord.w3x"
|
||||||
//FilePath="Maps\Campaign\NightElf03.w3m"
|
//FilePath="Maps\Campaign\NightElf03.w3m"
|
||||||
FilePath="PhoenixAttack.w3x"
|
//FilePath="PhoenixAttack.w3x"
|
||||||
|
FilePath="LightEnvironmentTest.w3x"
|
||||||
|
//FilePath="TorchLight2.w3x"
|
@ -86,32 +86,31 @@ public class Shaders {
|
|||||||
+ ", lightDirection), 0.0, 1.0);\r\n" + //
|
+ ", lightDirection), 0.0, 1.0);\r\n" + //
|
||||||
" if(lightFactorContribution.r > 1.0 || lightFactorContribution.g > 1.0 || lightFactorContribution.b > 1.0) {\r\n"
|
" if(lightFactorContribution.r > 1.0 || lightFactorContribution.g > 1.0 || lightFactorContribution.b > 1.0) {\r\n"
|
||||||
+ //
|
+ //
|
||||||
" lightFactorContribution = normalize(lightFactorContribution);\r\n" + //
|
" lightFactorContribution = clamp(lightFactorContribution, 0.0, 1.0);\r\n" + //
|
||||||
" }\r\n" + //
|
" }\r\n" + //
|
||||||
" lightFactor += lightFactorContribution + lightAmbColor.a * lightAmbColor.rgb;\r\n" + //
|
" lightFactor += lightFactorContribution + lightAmbColor.a * lightAmbColor.rgb;\r\n" + //
|
||||||
" } else {\r\n" + //
|
" } else {\r\n" + //
|
||||||
" // Omnidirectional light;\r\n" + //
|
" // Omnidirectional light;\r\n" + //
|
||||||
" vec3 deltaBtwn = " + positionName + " - lightPosition.xyz;\r\n" + //
|
" vec3 deltaBtwn = " + positionName + " - lightPosition.xyz;\r\n" + //
|
||||||
" float dist = length(" + positionName + " - vec3(lightPosition." + (terrain ? "xyw" : "xyz")
|
" float dist = length(" + positionName + " - vec3(lightPosition." + (terrain ? "xyz" : "xyz")
|
||||||
+ "));\r\n" + //
|
+ ")) / 64.0 + 1.0;\r\n" + //
|
||||||
" float attenuationStart = lightExtra.y;\r\n" + //
|
" vec3 lightDirection = normalize(-deltaBtwn);\r\n" + //
|
||||||
" float attenuationEnd = lightExtra.z;\r\n" + //
|
" vec3 lightFactorContribution = (lightColor.a/(pow(dist, 2.0))) * lightColor.rgb * clamp(dot("
|
||||||
" if( dist <= attenuationEnd ) {\r\n" + //
|
|
||||||
" float attenuationDist = clamp((dist-attenuationStart), 0.001, (attenuationEnd-attenuationStart));\r\n"
|
|
||||||
+ //
|
|
||||||
" float attenuationFactor = 1.0/(attenuationDist);\r\n" + //
|
|
||||||
" vec3 lightDirection = -deltaBtwn;\r\n" + //
|
|
||||||
" vec3 lightFactorContribution = attenuationFactor * lightColor.a * lightColor.rgb * clamp(dot("
|
|
||||||
+ normalName + ", lightDirection), 0.0, 1.0);\r\n" + //
|
+ normalName + ", lightDirection), 0.0, 1.0);\r\n" + //
|
||||||
" if(lightFactorContribution.r > 1.0 || lightFactorContribution.g > 1.0 || lightFactorContribution.b > 1.0) {\r\n"
|
" if(lightFactorContribution.r > 1.0 || lightFactorContribution.g > 1.0 || lightFactorContribution.b > 1.0) {\r\n"
|
||||||
+ //
|
+ //
|
||||||
" lightFactorContribution = normalize(lightFactorContribution);\r\n" + //
|
" lightFactorContribution = clamp(lightFactorContribution, 0.0, 1.0);\r\n" + //
|
||||||
" }\r\n" + //
|
" }\r\n" + //
|
||||||
" lightFactor += lightFactorContribution + attenuationFactor * lightAmbColor.a * lightAmbColor.rgb;\r\n"
|
" lightFactor += lightFactorContribution + (lightAmbColor.a/(pow(dist, 2.0))) * lightAmbColor.rgb;\r\n"
|
||||||
+ //
|
+ //
|
||||||
" \r\n" + //
|
|
||||||
" }\r\n" + //
|
" }\r\n" + //
|
||||||
" }\r\n" + //
|
" }\r\n";// + //
|
||||||
" }\r\n";
|
|
||||||
|
// " vec4 sRGB = vec4(lightFactor, 1.0);" + //
|
||||||
|
// " bvec4 cutoff = lessThan(sRGB, vec4(0.04045));" + //
|
||||||
|
// " vec4 higher = pow((sRGB + vec4(0.055))/vec4(1.055), vec4(2.4));" + //
|
||||||
|
// " vec4 lower = sRGB/vec4(12.92);" + //
|
||||||
|
// "" + //
|
||||||
|
// " lightFactor = (higher * (vec4(1.0) - vec4(cutoff)) + lower * vec4(cutoff)).xyz;";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -763,6 +763,7 @@ public class MdxComplexInstance extends ModelInstance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setFrameByRatio(final float ratioOfAnimationCompleted) {
|
public void setFrameByRatio(final float ratioOfAnimationCompleted) {
|
||||||
|
if (this.sequence != -1) {
|
||||||
final Sequence currentlyPlayingSequence = ((MdxModel) this.model).sequences.get(this.sequence);
|
final Sequence currentlyPlayingSequence = ((MdxModel) this.model).sequences.get(this.sequence);
|
||||||
this.floatingFrame = currentlyPlayingSequence.getInterval()[0]
|
this.floatingFrame = currentlyPlayingSequence.getInterval()[0]
|
||||||
+ ((currentlyPlayingSequence.getInterval()[1] - currentlyPlayingSequence.getInterval()[0])
|
+ ((currentlyPlayingSequence.getInterval()[1] - currentlyPlayingSequence.getInterval()[0])
|
||||||
@ -770,3 +771,4 @@ public class MdxComplexInstance extends ModelInstance {
|
|||||||
this.frame = (int) this.floatingFrame;
|
this.frame = (int) this.floatingFrame;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -102,7 +102,8 @@ public final class SdSequence<TYPE> {
|
|||||||
if (!this.constant) {
|
if (!this.constant) {
|
||||||
// If there is no opening keyframe for this sequence, inject one
|
// If there is no opening keyframe for this sequence, inject one
|
||||||
// with the default value.
|
// with the default value.
|
||||||
if (framesBuilder.get(0) != start) {
|
final boolean hasStart = framesBuilder.get(0) == start;
|
||||||
|
if (!hasStart) {
|
||||||
framesBuilder.add(start);
|
framesBuilder.add(start);
|
||||||
valuesBuilder.add(defval);
|
valuesBuilder.add(defval);
|
||||||
|
|
||||||
@ -116,11 +117,12 @@ public final class SdSequence<TYPE> {
|
|||||||
// with the default value.
|
// with the default value.
|
||||||
if (framesBuilder.get(framesBuilder.size() - 1) != end) {
|
if (framesBuilder.get(framesBuilder.size() - 1) != end) {
|
||||||
framesBuilder.add(end);
|
framesBuilder.add(end);
|
||||||
valuesBuilder.add(valuesBuilder.get(valuesBuilder.size() - 1));
|
final int sourceIndex = hasStart ? 0 : (valuesBuilder.size() - 1);
|
||||||
|
valuesBuilder.add(valuesBuilder.get(sourceIndex));
|
||||||
|
|
||||||
if (interpolationType > 1) {
|
if (interpolationType > 1) {
|
||||||
inTansBuilder.add(inTansBuilder.get(inTansBuilder.size() - 1));
|
inTansBuilder.add(inTansBuilder.get(sourceIndex));
|
||||||
outTansBuilder.add(outTansBuilder.get(outTansBuilder.size() - 1));
|
outTansBuilder.add(outTansBuilder.get(sourceIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,9 +52,9 @@ public class W3xScenePortraitLightManager implements SceneLightManager, W3xScene
|
|||||||
this.unitLightCount = 0;
|
this.unitLightCount = 0;
|
||||||
this.lightDataCopyHeap.clear();
|
this.lightDataCopyHeap.clear();
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
if (this.viewer.dncTarget != null) {
|
if (this.viewer.dncUnitDay != null) {
|
||||||
if (!this.viewer.dncTarget.lights.isEmpty()) {
|
if (!this.viewer.dncUnitDay.lights.isEmpty()) {
|
||||||
this.viewer.dncTarget.lights.get(0).bind(0, this.lightDataCopyHeap);
|
this.viewer.dncUnitDay.lights.get(0).bind(0, this.lightDataCopyHeap);
|
||||||
offset += 16;
|
offset += 16;
|
||||||
this.unitLightCount++;
|
this.unitLightCount++;
|
||||||
}
|
}
|
||||||
|
@ -158,6 +158,7 @@ public class War3MapViewer extends ModelViewer {
|
|||||||
private DataTable unitGlobalStrings;
|
private DataTable unitGlobalStrings;
|
||||||
private MdxComplexInstance confirmationInstance;
|
private MdxComplexInstance confirmationInstance;
|
||||||
public MdxComplexInstance dncUnit;
|
public MdxComplexInstance dncUnit;
|
||||||
|
public MdxComplexInstance dncUnitDay;
|
||||||
public MdxComplexInstance dncTerrain;
|
public MdxComplexInstance dncTerrain;
|
||||||
public MdxComplexInstance dncTarget;
|
public MdxComplexInstance dncTarget;
|
||||||
public CSimulation simulation;
|
public CSimulation simulation;
|
||||||
@ -927,6 +928,8 @@ public class War3MapViewer extends ModelViewer {
|
|||||||
this.dncUnit.setFrameByRatio(
|
this.dncUnit.setFrameByRatio(
|
||||||
this.simulation.getGameTimeOfDay() / this.simulation.getGameplayConstants().getGameDayHours());
|
this.simulation.getGameTimeOfDay() / this.simulation.getGameplayConstants().getGameDayHours());
|
||||||
this.dncUnit.update(rawDeltaTime, null);
|
this.dncUnit.update(rawDeltaTime, null);
|
||||||
|
this.dncUnitDay.setFrameByRatio(0.5f);
|
||||||
|
this.dncUnitDay.update(rawDeltaTime, null);
|
||||||
this.dncTarget.setFrameByRatio(
|
this.dncTarget.setFrameByRatio(
|
||||||
this.simulation.getGameTimeOfDay() / this.simulation.getGameplayConstants().getGameDayHours());
|
this.simulation.getGameTimeOfDay() / this.simulation.getGameplayConstants().getGameDayHours());
|
||||||
this.dncTarget.update(rawDeltaTime, null);
|
this.dncTarget.update(rawDeltaTime, null);
|
||||||
@ -1281,6 +1284,9 @@ public class War3MapViewer extends ModelViewer {
|
|||||||
this.dncUnit = (MdxComplexInstance) unitDNCModel.addInstance();
|
this.dncUnit = (MdxComplexInstance) unitDNCModel.addInstance();
|
||||||
this.dncUnit.setSequenceLoopMode(SequenceLoopMode.ALWAYS_LOOP);
|
this.dncUnit.setSequenceLoopMode(SequenceLoopMode.ALWAYS_LOOP);
|
||||||
this.dncUnit.setSequence(0);
|
this.dncUnit.setSequence(0);
|
||||||
|
this.dncUnitDay = (MdxComplexInstance) unitDNCModel.addInstance();
|
||||||
|
this.dncUnitDay.setSequenceLoopMode(SequenceLoopMode.ALWAYS_LOOP);
|
||||||
|
this.dncUnitDay.setSequence(0);
|
||||||
final MdxModel targetDNCModel = (MdxModel) load(
|
final MdxModel targetDNCModel = (MdxModel) load(
|
||||||
mdx("Environment\\DNC\\DNCLordaeron\\DNCLordaeronTarget\\DNCLordaeronTarget.mdl"), PathSolver.DEFAULT,
|
mdx("Environment\\DNC\\DNCLordaeron\\DNCLordaeronTarget\\DNCLordaeronTarget.mdl"), PathSolver.DEFAULT,
|
||||||
null);
|
null);
|
||||||
|
Loading…
Reference in New Issue
Block a user