Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
MrShoor committed Sep 1, 2016
1 parent fd69479 commit 300f415
Show file tree
Hide file tree
Showing 11 changed files with 826 additions and 0 deletions.
170 changes: 170 additions & 0 deletions InputLagDemo.lpi
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="InputLagDemo"/>
<ResourceType Value="res"/>
<Icon Value="0"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="3">
<Item1 Name="Default" Default="True"/>
<Item2 Name="Debug">
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="InputLagDemo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<IncludeAssertionCode Value="True"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<Checks>
<IOChecks Value="True"/>
<RangeChecks Value="True"/>
<OverflowChecks Value="True"/>
<StackChecks Value="True"/>
</Checks>
</CodeGeneration>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2Set"/>
<UseHeaptrc Value="True"/>
<UseExternalDbgSyms Value="True"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
<IgnoredMessages idx5024="True"/>
</CompilerMessages>
</Other>
</CompilerOptions>
</Item2>
<Item3 Name="Release">
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="InputLagDemo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<CodeGeneration>
<SmartLinkUnit Value="True"/>
<Optimizations>
<OptimizationLevel Value="3"/>
</Optimizations>
</CodeGeneration>
<Linking>
<Debugging>
<GenerateDebugInfo Value="False"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
<IgnoredMessages idx5024="True"/>
</CompilerMessages>
</Other>
</CompilerOptions>
</Item3>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="3">
<Item1>
<PackageName Value="AvalancheUtils"/>
</Item1>
<Item2>
<PackageName Value="Avalanche"/>
</Item2>
<Item3>
<PackageName Value="LCL"/>
</Item3>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="InputLagDemo.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="untmain.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="frmMain"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="untMain"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="InputLagDemo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
<IgnoredMessages idx5024="True"/>
</CompilerMessages>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>
20 changes: 20 additions & 0 deletions InputLagDemo.lpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
program InputLagDemo;

{$mode objfpc}{$H+}

uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, untMain;

{$R *.res}

begin
RequireDerivedFormResource := True;
Application.Initialize;
Application.CreateForm(TfrmMain, frmMain);
Application.Run;
end.

Binary file added InputLagDemo.res
Binary file not shown.
7 changes: 7 additions & 0 deletions shaders/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CC=apcc
ShaderName=shaders

all:
$(CC) $(ShaderName).json

clean:
46 changes: 46 additions & 0 deletions shaders/base.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "hlsl.h"
#include "matrices.h"

struct VS_Input {
float3 vsCoord : vsCoord;
float3 vsNormal : vsNormal;
float3 aiPosition: aiPosition;
float4 aiColor : aiColor;
};

struct VS_Output {
float4 Pos : SV_Position;
float3 Normal : Normal;
float3 ViewPos: ViewPos;
float4 Color : Color;
};

float CycleCount;

VS_Output VS(VS_Input In) {
VS_Output Out;
float4 crd = float4(In.vsCoord + In.aiPosition, 1.0);
Out.Pos = mul(crd, VP_Matrix);
Out.Normal = mul(In.vsNormal, (float3x3)V_Matrix);
Out.ViewPos = mul(crd, V_Matrix).xyz;

float4 sn = 0;
for (int i = 0; i<CycleCount; i++) {
sn += sin(i*1.5);
}
sn *= 0.00001;

Out.Color = In.aiColor+sn;
return Out;
}

struct PS_Output {
float4 Color : SV_Target0;
};

PS_Output PS(VS_Output In) {
PS_Output Out;
float3 n = normalize(In.Normal);
Out.Color = max(0.0, -dot(normalize(In.ViewPos), n)) * In.Color;
return Out;
}
51 changes: 51 additions & 0 deletions shaders/hlsl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#ifndef HLSL_H
#define HLSL_H

#define in
#define out
#define inout

struct float2 {
float x, y, r, g;
float2 xx, xy, yx, yy;
float3 xxy;
float4 xxyy;
};

struct float3 {
float x, y, z, r, g, b;
float2 xx, xy, xz, yx, yy, yz, zz;
float3 xxy, yyz;
};

struct float4 {
float x, y, z, w, r, g, b, a;
float2 xx, xy, xz, xw, yx, yy, yz, yw, zw, zz;
float3 xyz, rgb, yyz;
};

#define SamplerState int

template<gentype> struct Texture2D{
float4 Sample(SamplerState, gentype texcoord);
};

void discard;
float sin(float rad);
float cos(float rad);
float sqrt(float v);
template<gentype> float sign(gentype v);
template<gentype> float length(gentype v);
template<gentype> float dot(gentype v);
template<gentype> gentype sign(gentype v);
template<gentype> gentype cross(gentype v);
template<gentype> gentype normalize(gentype v);
template<gentype> gentype min(gentype v);
template<gentype> gentype max(gentype v);
template<gentype> gentype abs(gentype v);
template<gentype> gentype mul(gentype val1, gentype val2);
template<gentype> gentype lerp(gentype min, gentype max, float k);
template<gentype> gentype clamp(gentype v, gentype minval, gentype maxval);

#endif /* HLSL_H */

16 changes: 16 additions & 0 deletions shaders/matrices.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef MATRICES_H
#define MATRICES_H
#pragma pack_matrix( row_major )
float4x4 M_Matrix;
float4x4 MVP_Matrix;
float4x4 MV_Matrix;
float4x4 P_Matrix;
float4x4 M_InverseMatrix;
float4x4 MVP_InverseMatrix;
float4x4 MV_InverseMatrix;
float4x4 P_InverseMatrix;
float4x4 VP_Matrix;
float4x4 VP_InverseMatrix;
float4x4 V_Matrix;
float4x4 V_InverseMatrix;
#endif /* MATRICES_H */
21 changes: 21 additions & 0 deletions shaders/shaders.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"fxc_params" : "/nologo /O3 /Zi /Gec",
"HLSLcc_lang" : 330,
"HLSLcc_flags": ["HLSLCC_FLAG_DISABLE_GLOBALS_STRUCT",
"HLSLCC_FLAG_INOUT_SEMANTIC_NAMES",
"HLSLCC_FLAG_DISABLE_EXPLICIT_LOCATIONS"],
"OGLTranslate" : true,
"OutDir" : "!Out",
"VertexEntry" : "VS",
"FragmentEntry" : "PS",
"VertexTarget" : "vs_4_0",
"FragmentTarget" : "ps_4_0",
"Programs":[
{
"Name" : "base",
"Vertex" : "base.cpp",
"Fragment" : "base.cpp",
"Path" :[""]
}
]
}
2 changes: 2 additions & 0 deletions shaders/shaders.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DX_base RCDATA "!Out\DX_base.hlsl"
OGL_base RCDATA "!Out\OGL_base.glsl"
Loading

0 comments on commit 300f415

Please sign in to comment.