Hey jd_zoo
I started with the water effect, as you might figure out what you need to make your project working.
Every Demo I do like this, will still need the SP_ShaderManipulation.agc file to load the encrypted shader, which I obvously can't share, but I guess the Demo code itself I can just put here for the start.
//##########################################################
//#### AppGameKit - Shader Pack 2017 Jan Bögemann ####
//#### Project: Water ####
//#### Created: 2017-05-27 ####
//##########################################################
//#### AppGameKit - Shader Pack includes ####
#include ".\..\Templates\ShaderPack\Includes\SP_Clipping.agc"
#include ".\..\Templates\ShaderPack\Includes\SP_ShaderManipulation.agc"
#include ".\..\Templates\ShaderPack\Includes\SP_Common.agc"
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Water" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 100, 100 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 60, 0 )
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
SetGenerateMipmaps(1)
SetResolutionMode(1)
SetAntialiasMode(1)
// SP_ObjectData is needed to use SP_Clipping.agc
type SP_ObjectData
ObjectID
MeshID
ShaderID
EffectID
Visible
endtype
global SP_Global as SP_ObjectData[]
// MatData is used for the Level Materials
type MatData
Diffuse
Normal
Specular
Illumination
endtype
global Material as MatData[]
// Initialize General Scene variables
global SP_ReadRawFiles
SP_ReadRawFiles=0
InvertedDepth=IsInvertedDepth()
DeviceWidth=GetDeviceWidth()
DeviceHeight=GetDeviceHeight()
CameraNear#=1
CameraFar#=1000
SunRed#=255
SunGreen#=229.5
SunBlue#=178.5
SunDirX#=-0.3714
SunDirY#=-0.7428
SunDirZ#=0.5571
SetCameraRange(1,CameraNear#,CameraFar#)
SetSunDirection(SunDirX#,SunDirY#,SunDirZ#)
SetSunColor(SunRed#,SunGreen#,SunBlue#)
SetAmbientColor(76,76,76)
SetClearColor(0,0,0)
global SP_QuadID
SP_QuadID=CreateObjectQuad()
// Create Render Images
SP_Depth_CurrentImageID=CreateRenderImage(DeviceWidth,DeviceHeight,1,0)
SP_Depth_PrevImageID=CreateRenderImage(DeviceWidth,DeviceHeight,1,0)
SP_Water_Reflection_ImageID=CreateRenderImage(DeviceWidth*0.25,DeviceHeight*0.25,0,0)
SP_Water_Refraction_ImageID=CreateRenderImage(DeviceWidth*0.25,DeviceHeight*0.25,0,0)
SP_Water_Atlas_ImageID=CreateRenderImage(DeviceWidth*0.25,DeviceHeight*0.25,0,0)
// Load Shader
SP_AtlasShaderID=SP_LoadCustomFullscreenShader("Shader/AtlasCombine.ps")
SP_Water_ShaderID=SP_LoadCustomShader("Shader/Water.vs","Shader/Water.ps")
// Create Water Object
WaterNormalImageID=LoadImage("waterNormal.png")
SetImageWrapU(WaterNormalImageID,1)
SetImageWrapV(WaterNormalImageID,1)
WaterObjectID=CreateObjectPlane(50,50)
RotateObjectLocalX(WaterObjectID,90)
FixObjectPivot(WaterObjectID)
SetObjectPosition(WaterObjectID,0,-10,40)
SetObjectUVScale(WaterObjectID,0,8,8)
// Initialize Shader Uniforms for the Water
SetShaderConstantByName(SP_Water_ShaderID,"cameraRange",CameraNear#,CameraFar#,0,0)
SetShaderConstantByName(SP_Water_ShaderID,"sunDir",SunDirX#,SunDirY#,SunDirZ#,0)
SetShaderConstantByName(SP_Water_ShaderID,"sunColor",SunRed#/255.0,SunGreen#/255.0,SunBlue#/255.0,0)
SetShaderConstantByName(SP_Water_ShaderID,"waterDepthScale",0.1,0,0,0)
SetShaderConstantByName(SP_Water_ShaderID,"waterDepthColorScale",1.0,0,0,0)
SetShaderConstantByName(SP_Water_ShaderID,"waterDepthColor",0.12, 0.22, 0.22,0)
SetShaderConstantByName(SP_Water_ShaderID,"waterWaveSpeed",0.04,0,0,0)
SetShaderConstantByName(SP_Water_ShaderID,"waterWaveStrength",0.2,0,0,0)
SetShaderConstantByName(SP_Water_ShaderID,"waterShineDamper",20.0,0,0,0)
SetShaderConstantByName(SP_Water_ShaderID,"waterReflectivity",0.1,0,0,0)
SetShaderConstantByName(SP_Water_ShaderID,"invertedDepth",InvertedDepth,0,0,0)
SP_Water_Height#=GetObjectY(WaterObjectID)
SP_Water_RefractionHeightScale#=0.999
//~ SetObjectImage(ObjectID,DuDvImageID,0)
SetObjectImage(WaterObjectID,WaterNormalImageID,1)
SetObjectImage(WaterObjectID,SP_Depth_CurrentImageID,2)
SetObjectImage(WaterObjectID,SP_Water_Atlas_ImageID,3)
SetObjectColor(WaterObjectID,32,64,128,128)
SetObjectShader(WaterObjectID,SP_Water_ShaderID)
SetObjectTransparency(WaterObjectID,1)
// Create Lights
LightID as integer[]
for i=1 to 5
CreatePointLight(i,random(0,40)-20,random(0,20)-10,random(0,50),40,random(10,255),random(10,255),random(10,255))
LightID.insert(i)
next i
// Load World
WorldObjectID=LoadWorld("Map/SP_Showcase.x")
// Setup Camera
SetCameraPosition(1,20,-6,50)
SetCameraRotation(1,10,230,0)
// Setup Button
ButtonSize#=GetVirtualHeight()*0.25
AddVirtualButton(1,GetScreenBoundsRight()-ButtonSize#*0.5,GetScreenBoundsBottom()-ButtonSize#*0.5,ButtonSize#)
SetVirtualButtonText(1,"Light")
do
if GetRawKeyState(KEY_SHIFT) and GetRawKeyPressed(KEY_S) then NoHudSwitch=1-NoHudSwitch
SetVirtualButtonPosition(1,GetScreenBoundsRight()-ButtonSize#*0.5,GetScreenBoundsBottom()-ButtonSize#*0.5)
SetVirtualButtonVisible(1,1-NoHudSwitch)
if NoHudSwitch=0
Print("Water Effect")
Print("Use W,A,S,D or the Joystick to move the camera")
Print("FPS: "+str(ScreenFPS(),0))
endif
if GetRawKeyState(KEY_ESC) then exit
if GetVirtualButtonPressed(1)=1
SetPointLightPosition(LightID[0],GetCameraX(1),GetCameraY(1),GetCameraZ(1))
SetPointLightColor(LightID[0],random(10,255),random(10,255),random(10,255))
endif
SP_ControlCamera()
Angle#=Angle#+GetFrameTime()*16.0
// Sync and Water Rendering
Update(0)
// Render Depth Image
SetObjectVisible(WaterObjectID,0)
SetRenderToImage(0,SP_Depth_CurrentImageID)
ClearScreen()
Render3D()
SetObjectVisible(WaterObjectID,1)
TempImageID=SP_Depth_CurrentImageID
SP_Depth_CurrentImageID=SP_Depth_PrevImageID
SP_Depth_PrevImageID=TempImageID
// Render Reflection Image
TempCameraX#=GetCameraX(1)
TempCameraY#=GetCameraY(1)
TempCameraZ#=GetCameraZ(1)
TempCameraAngleX#=GetCameraAngleX(1)
TempCameraAngleY#=GetCameraAngleY(1)
TempCameraAngleZ#=GetCameraAngleZ(1)
SetObjectVisible(WaterObjectID,0)
SetCameraPosition(1,TempCameraX#,SP_Water_Height#-(TempCameraY#-SP_Water_Height#),TempCameraZ#)
SetCameraRotation(1,-TempCameraAngleX#,TempCameraAngleY#,-TempCameraAngleZ#)
if TempCameraY#>=SP_Water_Height#
SP_Clipping_SetPlane(0,-1,0,SP_Water_Height#)
else
SP_Clipping_SetPlane(0,1,0,-SP_Water_Height#*SP_Water_RefractionHeightScale#)
endif
SetRenderToImage(SP_Water_Reflection_ImageID,-1)
ClearScreen()
Render3D()
// Render Refraction Image
SetCameraPosition(1,TempCameraX#,TempCameraY#,TempCameraZ#)
SetCameraRotation(1,TempCameraAngleX#,TempCameraAngleY#,TempCameraAngleZ#)
if TempCameraY#>=SP_Water_Height#
SP_Clipping_SetPlane(0,1,0,-SP_Water_Height#*SP_Water_RefractionHeightScale#)
else
SP_Clipping_SetPlane(0,-1,0,SP_Water_Height#)
endif
SetRenderToImage(SP_Water_Refraction_ImageID,-1)
ClearScreen()
Render3D()
SetObjectVisible(WaterObjectID,1)
SP_Clipping_SetPlane(0,-1,0,GetCameraY(1)-CameraFar#)
// Combine Reflection and Refraction into Atlas Image
SetRenderToImage(SP_Water_Atlas_ImageID,0)
SetObjectImage(SP_QuadID,SP_Water_Reflection_ImageID,0)
SetObjectImage(SP_QuadID,SP_Water_Refraction_ImageID,1)
SetObjectShader(SP_QuadID,SP_AtlasShaderID)
DrawObject(SP_QuadID)
// Manual Sync
SetRenderToScreen()
Render2DBack()
RenderShadowMap()
Render3D()
Render2DFront()
Swap()
loop
function LoadWorld(File$)
Count=CountStringTokens(File$,"/\")
Path$=GetStringToken(File$,"/\",Count-1)+"/"
WorldObjectID=LoadObjectWithChildren(File$)
SetObjectScalePermanent(WorldObjectID,0.1,0.1,0.1)
SetObjectScreenCulling(WorldObjectID,0) // portal culling would work best in this kind of level
local Suffix as string[2] = ["local","s","add"]
local Extension as string[1] = [".png",".jpg"]
for index=1 to GetObjectNumTextures(WorldObjectID)
DiffuseImageID=0
NormalImageID=0
SecularImageID=0
IlluminationImageID=0
DiffuseFile$=GetObjectTextureName(WorldObjectID,index)
DiffuseImageID=LoadImage(Path$+DiffuseFile$)
BaseName$=left(DiffuseFile$,len(DiffuseFile$)-len("d.png"))
for SuffixID=0 to Suffix.length
for ExtensionID=0 to Extension.length
CheckFile$=Path$+BaseName$+Suffix[SuffixID]+Extension[ExtensionID]
if GetFileExists(CheckFile$)
select SuffixID
case 0
NormalImageID=LoadImage(CheckFile$)
endcase
case 1
SecularImageID=LoadImage(CheckFile$)
endcase
case 2
IlluminationImageID=LoadImage(CheckFile$)
endcase
endselect
exit
endif
next ExtensionID
next SuffixID
AddMaterial(DiffuseImageID,NormalImageID,SecularImageID,IlluminationImageID)
next index
SetObjectMaterials(WorldObjectID)
RemoveMaterials()
endfunction WorldObjectID
function SetObjectMaterials(WorldObjectID)
for MeshID=1 to GetObjectNumMeshes(WorldObjectID)
if Material[MeshID-1].Illumination>0
SetObjectMeshNormalMap(WorldObjectID,MeshID,Material[MeshID-1].Normal)
SetObjectMeshImage(WorldObjectID,MeshID,Material[MeshID-1].Diffuse,0)
SP_Clipping_AddMesh(WorldObjectID,MeshID)
elseif Material[MeshID-1].Normal>0
SetObjectMeshNormalMap(WorldObjectID,MeshID,Material[MeshID-1].Normal)
SetObjectMeshImage(WorldObjectID,MeshID,Material[MeshID-1].Diffuse,0)
SP_Clipping_AddMesh(WorldObjectID,MeshID)
elseif Material[MeshID-1].Diffuse>0
SetObjectMeshImage(WorldObjectID,MeshID,Material[MeshID-1].Diffuse,0)
SP_Clipping_AddMesh(WorldObjectID,MeshID)
endif
next MeshID
endfunction
function AddMaterial(Diffuse,Normal,Specular,Illumination)
TempMaterial as MatData
if GetImageExists(Diffuse)
TempMaterial.Diffuse=Diffuse
SetImageWrapU(TempMaterial.Diffuse,1)
SetImageWrapV(TempMaterial.Diffuse,1)
endif
if GetImageExists(Normal)
TempMaterial.Normal=Normal
SetImageWrapU(TempMaterial.Normal,1)
SetImageWrapV(TempMaterial.Normal,1)
endif
if GetImageExists(Specular)
TempMaterial.Specular=Specular
SetImageWrapU(TempMaterial.Specular,1)
SetImageWrapV(TempMaterial.Specular,1)
endif
if GetImageExists(Illumination)
TempMaterial.Illumination=Illumination
SetImageWrapU(TempMaterial.Illumination,1)
SetImageWrapV(TempMaterial.Illumination,1)
endif
Material.insert(TempMaterial)
endfunction
function RemoveMaterials()
Material.length=-1
endfunction
Made it in 1hour i think, so if you have problems I'll update this post.
It may also not work with the current released version, so I might need to create a relase version again to get you up to date... we will see I guess