scripting updates; added new sample scripts; const updates;
This commit is contained in:
@@ -60,22 +60,22 @@ getprops(YourObject) on them (where YourObject is the object which is to be insp
|
||||
|
||||
## Common Tools
|
||||
This section describes the common tools for scripting which are not necessarily engine features.
|
||||
- signal(string name)
|
||||
- waitSignal(string name)
|
||||
- runProcess(function func)
|
||||
- killProcesses()
|
||||
- waitSeconds(float seconds)
|
||||
- getprops(table object)
|
||||
- len(table object)
|
||||
- backlog_post_list(table list)
|
||||
- fixedupdate()
|
||||
- update()
|
||||
- render()
|
||||
- getDeltaTime()
|
||||
- math.lerp(float a,b,t)
|
||||
- math.clamp(float x,min,max)
|
||||
- math.saturate(float x)
|
||||
- math.round(float x)
|
||||
- signal(string name) -- send a signal globally. This can wake up processes if there are any waiting on the same signal name
|
||||
- waitSignal(string name) -- wait until a specified signal arrives
|
||||
- runProcess(function func) -- start a new process
|
||||
- killProcesses() -- stop and remove all processes
|
||||
- waitSeconds(float seconds) -- wait until some time has passed (to be used from inside a process)
|
||||
- getprops(table object) -- get reflection data from object
|
||||
- len(table object) -- get the length of a table
|
||||
- backlog_post_list(table list) -- post table contents to the backlog
|
||||
- fixedupdate() -- wait for a fixed update step to be called (to be used from inside a process)
|
||||
- update() -- wait for variable update step to be called (to be used from inside a process)
|
||||
- render() -- wait for a render step to be called (to be used from inside a process)
|
||||
- getDeltaTime() -- returns the delta time in seconds (time passed sice previous update())
|
||||
- math.lerp(float a,b,t) -- linear interpolation
|
||||
- math.clamp(float x,min,max) -- clamp x between min and max
|
||||
- math.saturate(float x) -- clamp x between 0 and 1
|
||||
- math.round(float x) -- round x to nearest integer
|
||||
|
||||
## Engine manipulation
|
||||
The scripting API provides functions for the developer to manipulate engine behaviour or query it for information.
|
||||
@@ -84,11 +84,11 @@ The scripting API provides functions for the developer to manipulate engine beha
|
||||
The scripting console of the engine. Input text with the keyboard, run the input with the RETURN key. The script errors
|
||||
are also displayed here.
|
||||
The scripting API provides some functions which manipulate the BackLog. These functions are in he global scope:
|
||||
- backlog_clear()
|
||||
- backlog_post(string params,,,)
|
||||
- backlog_fontsize(int size)
|
||||
- backlog_isactive() : boolean result
|
||||
- backlog_fontrowspacing(int spacing)
|
||||
- backlog_clear() -- remove all entries from the backlog
|
||||
- backlog_post(string params,,,) -- post a string to the backlog
|
||||
- backlog_fontsize(int size) -- modify the fint size of the backlog
|
||||
- backlog_isactive() : boolean result -- returns true if the backlog is active, false otherwise
|
||||
- backlog_fontrowspacing(int spacing) -- set a row spacing to the backlog
|
||||
|
||||
### Renderer
|
||||
This is the graphics renderer, which is also responsible for managing the scene graph which consists of keeping track of
|
||||
@@ -117,9 +117,10 @@ You can use the Renderer with the following functions, all of which are in the g
|
||||
- SetDebugForceFieldsEnabled(bool enabled)
|
||||
- SetVSyncEnabled(opt bool enabled)
|
||||
- SetOcclusionCullingEnabled(bool enabled)
|
||||
- SetPhysicsParams(opt bool rigidBodyPhysicsEnabled, opt bool softBodyPhysicsEnabled, opt int softBodyIterationCount)
|
||||
- Pick(Ray ray, opt PICKTYPE pickType, opt uint layerMask) : Object? object, Vector position,normal, float distance -- Perform ray-picking in the scene. pickType is a bitmask specifying object types to check against. layerMask is a bitmask specifying which layers to check against
|
||||
- Pick(Ray ray, opt PICKTYPE pickType, opt uint layerMask) : int entity, Vector position,normal, float distance -- Perform ray-picking in the scene. pickType is a bitmask specifying object types to check against. layerMask is a bitmask specifying which layers to check against
|
||||
- DrawLine(Vector origin,end, opt Vector color)
|
||||
- DrawPoint(Vector origin, opt float size, opt Vector color)
|
||||
- DrawBox(Matrix boxMatrix, opt Vector color)
|
||||
- PutWaterRipple(String imagename, Vector position)
|
||||
- PutDecal(Decal decal)
|
||||
- PutEnvProbe(Vector pos)
|
||||
@@ -336,6 +337,14 @@ Describes an orientation in 3D space.
|
||||
- UpdateCamera() -- update the camera matrices
|
||||
- TransformCamera(TransformComponent transform) -- copies the transform's orientation to the camera. Camera matrices are not updated immediately. They will be updated by the Scene::Update() (if the camera is part of the scene), or by manually calling UpdateCamera()
|
||||
|
||||
#### AnimationComponent
|
||||
- Play()
|
||||
- Stop()
|
||||
- Pause()
|
||||
|
||||
#### MaterialComponent
|
||||
- SetBaseColor()
|
||||
- SetEmissiveColor()
|
||||
|
||||
## High Level Interface
|
||||
### MainComponent
|
||||
@@ -440,6 +449,36 @@ It inherits functions from RenderPath2D.
|
||||
- AddLoadingTask(string taskScript)
|
||||
- OnFinished(string taskScript)
|
||||
|
||||
### Intersects
|
||||
|
||||
#### Ray
|
||||
A ray is defined by an origin Vector and a normalized direction Vector. It can be used to intersect with other primitives or the scene
|
||||
- [constructor]Ray(Vector origin,direction)
|
||||
- Intersects(AABB aabb) : bool result
|
||||
- Intersects(Sphere sphere) : bool result
|
||||
- GetOrigin() : Vector result
|
||||
- GetDirection() : Vector result
|
||||
|
||||
#### AABB
|
||||
Axis Aligned Bounding Box. Can be intersected with other primitives.
|
||||
- [constructor]AABB(Vector min,max)
|
||||
- Intersects(AABB aabb) : int result -- result can be 0 (outside, no intersection), 1 (intersection), 2 (completely inside)
|
||||
- Intersects(Sphere sphere) : bool result
|
||||
- Intersects(Ray ray) : bool result
|
||||
- GetMin() : Vector result
|
||||
- GetMax() : Vector result
|
||||
- GetCenter() : Vector result
|
||||
- GetHalfExtents() : Vector result
|
||||
|
||||
#### Sphere
|
||||
Sphere defined by center Vector and radius. Can be intersected with other primitives.
|
||||
- [constructor]Sphere(Vector center, float radius)
|
||||
- Intersects(AABB aabb) : bool result
|
||||
- Intersects(Sphere sphere) : bool result
|
||||
- Intersects(Ray ray) : bool result
|
||||
- GetCenter() : Vector result
|
||||
- GetRadius() : float result
|
||||
|
||||
### Network
|
||||
Here are the network communication features.
|
||||
- TODO
|
||||
@@ -459,9 +498,9 @@ These provide functions to check the state of the input devices.
|
||||
Query input devices
|
||||
- [outer]input : InputManager
|
||||
- [void-constructor]InputManager()
|
||||
- Down(int code, opt int type = KEYBOARD)
|
||||
- Press(int code, opt int type = KEYBOARD)
|
||||
- Hold(int code, opt int duration = 30, opt boolean continuous = false, opt int type = KEYBOARD)
|
||||
- Down(int code, opt int type = KEYBOARD) : bool result -- Check whether a button is currently being held down
|
||||
- Press(int code, opt int type = KEYBOARD) : bool result -- Check whether a button has just been pushed that wasn't before
|
||||
- Hold(int code, opt int duration = 30, opt boolean continuous = false, opt int type = KEYBOARD) : bool result -- Check whether a button was being held down for a specific duration (nunmber of frames). If continuous == true, than it will also return true after the duration was reached
|
||||
- GetPointer() : Vector result
|
||||
- SetPointer(Vector pos)
|
||||
- HidePointer(bool visible)
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace tinygltf
|
||||
void RegisterTexture2D(tinygltf::Image *image, const string& type_name)
|
||||
{
|
||||
// We will load the texture2d by hand here and register to the resource manager (if it was not already registered)
|
||||
if (wiResourceManager::GetGlobal().get(wiHashString(image->uri)) == nullptr)
|
||||
if (wiResourceManager::GetGlobal().get(wiHashString(image->uri)).data == nullptr)
|
||||
{
|
||||
int width = image->width;
|
||||
int height = image->height;
|
||||
|
||||
@@ -336,6 +336,7 @@
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiInitializer.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiInputManager.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiInputManager_BindLua.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiIntersect_BindLua.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiJobSystem.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiLensFlare.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiPhysicsEngine.h" />
|
||||
@@ -670,6 +671,7 @@
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiInputManager.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiInputManager_BindLua.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiIntersect.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiIntersect_BindLua.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiJobSystem.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiLensFlare.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiPhysicsEngine_Bullet.cpp" />
|
||||
|
||||
@@ -1137,6 +1137,9 @@
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiIntersect.h">
|
||||
<Filter>ENGINE\Helpers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)wiIntersect_BindLua.h">
|
||||
<Filter>ENGINE\Scripting\LuaBindings</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)LUA\lapi.c">
|
||||
@@ -1916,6 +1919,9 @@
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiIntersect.cpp">
|
||||
<Filter>ENGINE\Helpers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)wiIntersect_BindLua.cpp">
|
||||
<Filter>ENGINE\Scripting\LuaBindings</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="$(MSBuildThisFileDirectory)fonts\default_font.dds">
|
||||
|
||||
@@ -18,21 +18,21 @@ using namespace wiGraphicsTypes;
|
||||
namespace wiSceneSystem
|
||||
{
|
||||
|
||||
static VertexShader* vertexShader = nullptr;
|
||||
static PixelShader* pixelShader[wiEmittedParticle::PARTICLESHADERTYPE_COUNT] = {};
|
||||
static ComputeShader* kickoffUpdateCS = nullptr;
|
||||
static ComputeShader* finishUpdateCS = nullptr;
|
||||
static ComputeShader* emitCS = nullptr;
|
||||
static ComputeShader* emitCS_FROMMESH = nullptr;
|
||||
static ComputeShader* sphpartitionCS = nullptr;
|
||||
static ComputeShader* sphpartitionoffsetsCS = nullptr;
|
||||
static ComputeShader* sphpartitionoffsetsresetCS = nullptr;
|
||||
static ComputeShader* sphdensityCS = nullptr;
|
||||
static ComputeShader* sphforceCS = nullptr;
|
||||
static ComputeShader* simulateCS = nullptr;
|
||||
static ComputeShader* simulateCS_SORTING = nullptr;
|
||||
static ComputeShader* simulateCS_DEPTHCOLLISIONS = nullptr;
|
||||
static ComputeShader* simulateCS_SORTING_DEPTHCOLLISIONS = nullptr;
|
||||
static const VertexShader* vertexShader = nullptr;
|
||||
static const PixelShader* pixelShader[wiEmittedParticle::PARTICLESHADERTYPE_COUNT] = {};
|
||||
static const ComputeShader* kickoffUpdateCS = nullptr;
|
||||
static const ComputeShader* finishUpdateCS = nullptr;
|
||||
static const ComputeShader* emitCS = nullptr;
|
||||
static const ComputeShader* emitCS_FROMMESH = nullptr;
|
||||
static const ComputeShader* sphpartitionCS = nullptr;
|
||||
static const ComputeShader* sphpartitionoffsetsCS = nullptr;
|
||||
static const ComputeShader* sphpartitionoffsetsresetCS = nullptr;
|
||||
static const ComputeShader* sphdensityCS = nullptr;
|
||||
static const ComputeShader* sphforceCS = nullptr;
|
||||
static const ComputeShader* simulateCS = nullptr;
|
||||
static const ComputeShader* simulateCS_SORTING = nullptr;
|
||||
static const ComputeShader* simulateCS_DEPTHCOLLISIONS = nullptr;
|
||||
static const ComputeShader* simulateCS_SORTING_DEPTHCOLLISIONS = nullptr;
|
||||
|
||||
static BlendState blendStates[BLENDMODE_COUNT];
|
||||
static RasterizerState rasterizerState;
|
||||
@@ -621,25 +621,25 @@ void wiEmittedParticle::LoadShaders()
|
||||
{
|
||||
std::string path = wiRenderer::GetShaderPath();
|
||||
|
||||
vertexShader = static_cast<VertexShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticleVS.cso", wiResourceManager::VERTEXSHADER));
|
||||
vertexShader = static_cast<const VertexShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticleVS.cso", wiResourceManager::VERTEXSHADER));
|
||||
|
||||
pixelShader[SOFT] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticlePS_soft.cso", wiResourceManager::PIXELSHADER));
|
||||
pixelShader[SOFT_DISTORTION] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticlePS_soft_distortion.cso", wiResourceManager::PIXELSHADER));
|
||||
pixelShader[SIMPLEST] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticlePS_simplest.cso", wiResourceManager::PIXELSHADER));
|
||||
pixelShader[SOFT] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticlePS_soft.cso", wiResourceManager::PIXELSHADER));
|
||||
pixelShader[SOFT_DISTORTION] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticlePS_soft_distortion.cso", wiResourceManager::PIXELSHADER));
|
||||
pixelShader[SIMPLEST] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticlePS_simplest.cso", wiResourceManager::PIXELSHADER));
|
||||
|
||||
kickoffUpdateCS = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_kickoffUpdateCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
finishUpdateCS = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_finishUpdateCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
emitCS = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_emitCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
emitCS_FROMMESH = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_emitCS_FROMMESH.cso", wiResourceManager::COMPUTESHADER));
|
||||
sphpartitionCS = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_sphpartitionCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
sphpartitionoffsetsCS = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_sphpartitionoffsetsCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
sphpartitionoffsetsresetCS = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_sphpartitionoffsetsresetCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
sphdensityCS = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_sphdensityCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
sphforceCS = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_sphforceCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
simulateCS = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_simulateCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
simulateCS_SORTING = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_simulateCS_SORTING.cso", wiResourceManager::COMPUTESHADER));
|
||||
simulateCS_DEPTHCOLLISIONS = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_simulateCS_DEPTHCOLLISIONS.cso", wiResourceManager::COMPUTESHADER));
|
||||
simulateCS_SORTING_DEPTHCOLLISIONS = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_simulateCS_SORTING_DEPTHCOLLISIONS.cso", wiResourceManager::COMPUTESHADER));
|
||||
kickoffUpdateCS = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_kickoffUpdateCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
finishUpdateCS = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_finishUpdateCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
emitCS = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_emitCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
emitCS_FROMMESH = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_emitCS_FROMMESH.cso", wiResourceManager::COMPUTESHADER));
|
||||
sphpartitionCS = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_sphpartitionCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
sphpartitionoffsetsCS = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_sphpartitionoffsetsCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
sphpartitionoffsetsresetCS = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_sphpartitionoffsetsresetCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
sphdensityCS = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_sphdensityCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
sphforceCS = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_sphforceCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
simulateCS = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_simulateCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
simulateCS_SORTING = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_simulateCS_SORTING.cso", wiResourceManager::COMPUTESHADER));
|
||||
simulateCS_DEPTHCOLLISIONS = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_simulateCS_DEPTHCOLLISIONS.cso", wiResourceManager::COMPUTESHADER));
|
||||
simulateCS_SORTING_DEPTHCOLLISIONS = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "emittedparticle_simulateCS_SORTING_DEPTHCOLLISIONS.cso", wiResourceManager::COMPUTESHADER));
|
||||
|
||||
|
||||
GraphicsDevice* device = wiRenderer::GetDevice();
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
using namespace wiGraphicsTypes;
|
||||
|
||||
static ComputeShader* pRadix008A_CS = nullptr;
|
||||
static ComputeShader* pRadix008A_CS2 = nullptr;
|
||||
static const ComputeShader* pRadix008A_CS = nullptr;
|
||||
static const ComputeShader* pRadix008A_CS2 = nullptr;
|
||||
static ComputePSO PSO1;
|
||||
static ComputePSO PSO2;
|
||||
|
||||
@@ -231,8 +231,8 @@ void CSFFT_512x512_Data_t::LoadShaders()
|
||||
{
|
||||
std::string path = wiRenderer::GetShaderPath();
|
||||
|
||||
pRadix008A_CS = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path+ "fft_512x512_c2c_CS.cso", wiResourceManager::COMPUTESHADER));
|
||||
pRadix008A_CS2 = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "fft_512x512_c2c_v2_CS.cso", wiResourceManager::COMPUTESHADER));
|
||||
pRadix008A_CS = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path+ "fft_512x512_c2c_CS.cso", wiResourceManager::COMPUTESHADER));
|
||||
pRadix008A_CS2 = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "fft_512x512_c2c_v2_CS.cso", wiResourceManager::COMPUTESHADER));
|
||||
|
||||
GraphicsDevice* device = wiRenderer::GetDevice();
|
||||
|
||||
|
||||
+8
-10
@@ -37,9 +37,9 @@ namespace wiFont_Internal
|
||||
DepthStencilState depthStencilState;
|
||||
Sampler sampler;
|
||||
|
||||
VertexLayout *vertexLayout = nullptr;
|
||||
VertexShader *vertexShader = nullptr;
|
||||
PixelShader *pixelShader = nullptr;
|
||||
std::unique_ptr<VertexLayout> vertexLayout;
|
||||
const VertexShader *vertexShader = nullptr;
|
||||
const PixelShader *pixelShader = nullptr;
|
||||
GraphicsPSO *PSO = nullptr;
|
||||
|
||||
atomic_bool initialized = false;
|
||||
@@ -293,8 +293,6 @@ void wiFont::Initialize()
|
||||
void wiFont::CleanUp()
|
||||
{
|
||||
fontStyles.clear();
|
||||
SAFE_DELETE(vertexShader);
|
||||
SAFE_DELETE(pixelShader);
|
||||
}
|
||||
|
||||
void wiFont::LoadShaders()
|
||||
@@ -306,19 +304,19 @@ void wiFont::LoadShaders()
|
||||
{ "POSITION", 0, FORMAT_R16G16_SINT, 0, VertexLayoutDesc::APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "TEXCOORD", 0, FORMAT_R16G16_FLOAT, 0, VertexLayoutDesc::APPEND_ALIGNED_ELEMENT, INPUT_PER_VERTEX_DATA, 0 },
|
||||
};
|
||||
vertexShader = static_cast<VertexShader*>(wiResourceManager::GetShaderManager().add(path + "fontVS.cso", wiResourceManager::VERTEXSHADER));
|
||||
vertexShader = static_cast<const VertexShader*>(wiResourceManager::GetShaderManager().add(path + "fontVS.cso", wiResourceManager::VERTEXSHADER));
|
||||
|
||||
vertexLayout = new VertexLayout;
|
||||
wiRenderer::GetDevice()->CreateInputLayout(layout, ARRAYSIZE(layout), &vertexShader->code, vertexLayout);
|
||||
vertexLayout.reset(new VertexLayout);
|
||||
wiRenderer::GetDevice()->CreateInputLayout(layout, ARRAYSIZE(layout), &vertexShader->code, vertexLayout.get());
|
||||
|
||||
|
||||
pixelShader = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "fontPS.cso", wiResourceManager::PIXELSHADER));
|
||||
pixelShader = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "fontPS.cso", wiResourceManager::PIXELSHADER));
|
||||
|
||||
|
||||
GraphicsPSODesc desc;
|
||||
desc.vs = vertexShader;
|
||||
desc.ps = pixelShader;
|
||||
desc.il = vertexLayout;
|
||||
desc.il = vertexLayout.get();
|
||||
desc.bs = &blendState;
|
||||
desc.rs = &rasterizerState;
|
||||
desc.dss = &depthStencilState;
|
||||
|
||||
@@ -25,7 +25,7 @@ enum CSTYPES_BVH
|
||||
CSTYPE_BVH_PROPAGATEAABB,
|
||||
CSTYPE_BVH_COUNT
|
||||
};
|
||||
static ComputeShader* computeShaders[CSTYPE_BVH_COUNT] = {};
|
||||
static const ComputeShader* computeShaders[CSTYPE_BVH_COUNT] = {};
|
||||
static ComputePSO* CPSO[CSTYPE_BVH_COUNT] = {};
|
||||
|
||||
static GPUBuffer* constantBuffer = nullptr;
|
||||
@@ -510,12 +510,12 @@ void wiGPUBVH::LoadShaders()
|
||||
GraphicsDevice* device = wiRenderer::GetDevice();
|
||||
string SHADERPATH = wiRenderer::GetShaderPath();
|
||||
|
||||
computeShaders[CSTYPE_BVH_RESET] = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(SHADERPATH + "bvh_resetCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
computeShaders[CSTYPE_BVH_CLASSIFICATION] = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(SHADERPATH + "bvh_classificationCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
computeShaders[CSTYPE_BVH_KICKJOBS] = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(SHADERPATH + "bvh_kickjobsCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
computeShaders[CSTYPE_BVH_CLUSTERPROCESSOR] = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(SHADERPATH + "bvh_clusterprocessorCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
computeShaders[CSTYPE_BVH_HIERARCHY] = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(SHADERPATH + "bvh_hierarchyCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
computeShaders[CSTYPE_BVH_PROPAGATEAABB] = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(SHADERPATH + "bvh_propagateaabbCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
computeShaders[CSTYPE_BVH_RESET] = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(SHADERPATH + "bvh_resetCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
computeShaders[CSTYPE_BVH_CLASSIFICATION] = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(SHADERPATH + "bvh_classificationCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
computeShaders[CSTYPE_BVH_KICKJOBS] = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(SHADERPATH + "bvh_kickjobsCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
computeShaders[CSTYPE_BVH_CLUSTERPROCESSOR] = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(SHADERPATH + "bvh_clusterprocessorCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
computeShaders[CSTYPE_BVH_HIERARCHY] = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(SHADERPATH + "bvh_hierarchyCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
computeShaders[CSTYPE_BVH_PROPAGATEAABB] = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(SHADERPATH + "bvh_propagateaabbCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
|
||||
|
||||
for (int i = 0; i < CSTYPE_BVH_COUNT; ++i)
|
||||
|
||||
@@ -7,12 +7,12 @@ using namespace wiGraphicsTypes;
|
||||
|
||||
namespace wiGPUSortLib
|
||||
{
|
||||
static GPUBuffer* indirectBuffer = nullptr;
|
||||
static GPUBuffer* sortCB = nullptr;
|
||||
static ComputeShader* kickoffSortCS = nullptr;
|
||||
static ComputeShader* sortCS = nullptr;
|
||||
static ComputeShader* sortInnerCS = nullptr;
|
||||
static ComputeShader* sortStepCS = nullptr;
|
||||
static std::unique_ptr<GPUBuffer> indirectBuffer;
|
||||
static std::unique_ptr<GPUBuffer> sortCB;
|
||||
static const ComputeShader* kickoffSortCS = nullptr;
|
||||
static const ComputeShader* sortCS = nullptr;
|
||||
static const ComputeShader* sortInnerCS = nullptr;
|
||||
static const ComputeShader* sortStepCS = nullptr;
|
||||
static ComputePSO CPSO_kickoffSort;
|
||||
static ComputePSO CPSO_sort;
|
||||
static ComputePSO CPSO_sortInner;
|
||||
@@ -27,8 +27,8 @@ namespace wiGPUSortLib
|
||||
bd.BindFlags = BIND_CONSTANT_BUFFER;
|
||||
bd.MiscFlags = 0;
|
||||
bd.ByteWidth = sizeof(SortConstants);
|
||||
sortCB = new GPUBuffer;
|
||||
wiRenderer::GetDevice()->CreateBuffer(&bd, nullptr, sortCB);
|
||||
sortCB.reset(new GPUBuffer);
|
||||
wiRenderer::GetDevice()->CreateBuffer(&bd, nullptr, sortCB.get());
|
||||
|
||||
|
||||
bd.Usage = USAGE_DEFAULT;
|
||||
@@ -36,8 +36,8 @@ namespace wiGPUSortLib
|
||||
bd.BindFlags = BIND_UNORDERED_ACCESS;
|
||||
bd.MiscFlags = RESOURCE_MISC_DRAWINDIRECT_ARGS | RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS;
|
||||
bd.ByteWidth = sizeof(IndirectDispatchArgs);
|
||||
indirectBuffer = new GPUBuffer;
|
||||
wiRenderer::GetDevice()->CreateBuffer(&bd, nullptr, indirectBuffer);
|
||||
indirectBuffer.reset(new GPUBuffer);
|
||||
wiRenderer::GetDevice()->CreateBuffer(&bd, nullptr, indirectBuffer.get());
|
||||
|
||||
}
|
||||
|
||||
@@ -45,10 +45,10 @@ namespace wiGPUSortLib
|
||||
{
|
||||
std::string path = wiRenderer::GetShaderPath();
|
||||
|
||||
kickoffSortCS = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "gpusortlib_kickoffSortCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
sortCS = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "gpusortlib_sortCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
sortInnerCS = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "gpusortlib_sortInnerCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
sortStepCS = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "gpusortlib_sortStepCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
kickoffSortCS = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "gpusortlib_kickoffSortCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
sortCS = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "gpusortlib_sortCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
sortInnerCS = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "gpusortlib_sortInnerCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
sortStepCS = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "gpusortlib_sortStepCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
|
||||
|
||||
GraphicsDevice* device = wiRenderer::GetDevice();
|
||||
@@ -70,8 +70,6 @@ namespace wiGPUSortLib
|
||||
|
||||
void CleanUp()
|
||||
{
|
||||
SAFE_DELETE(indirectBuffer);
|
||||
SAFE_DELETE(sortCB);
|
||||
}
|
||||
|
||||
|
||||
@@ -92,8 +90,8 @@ namespace wiGPUSortLib
|
||||
|
||||
SortConstants sc;
|
||||
sc.counterReadOffset = counterReadOffset;
|
||||
device->UpdateBuffer(sortCB, &sc, threadID);
|
||||
device->BindConstantBuffer(CS, sortCB, CB_GETBINDSLOT(SortConstants), threadID);
|
||||
device->UpdateBuffer(sortCB.get(), &sc, threadID);
|
||||
device->BindConstantBuffer(CS, sortCB.get(), CB_GETBINDSLOT(SortConstants), threadID);
|
||||
|
||||
device->UnbindUAVs(0, 8, threadID);
|
||||
|
||||
@@ -107,7 +105,7 @@ namespace wiGPUSortLib
|
||||
device->BindResources(CS, res, 0, ARRAYSIZE(res), threadID);
|
||||
|
||||
GPUResource* uavs[] = {
|
||||
indirectBuffer,
|
||||
indirectBuffer.get(),
|
||||
};
|
||||
device->BindUAVs(CS, uavs, 0, ARRAYSIZE(uavs), threadID);
|
||||
|
||||
@@ -148,7 +146,7 @@ namespace wiGPUSortLib
|
||||
|
||||
// sort all buffers of size 512 (and presort bigger ones)
|
||||
device->BindComputePSO(&CPSO_sort, threadID);
|
||||
device->DispatchIndirect(indirectBuffer, 0, threadID);
|
||||
device->DispatchIndirect(indirectBuffer.get(), 0, threadID);
|
||||
device->UAVBarrier(uavs, ARRAYSIZE(uavs), threadID);
|
||||
}
|
||||
|
||||
@@ -191,8 +189,8 @@ namespace wiGPUSortLib
|
||||
}
|
||||
sc.counterReadOffset = counterReadOffset;
|
||||
|
||||
device->UpdateBuffer(sortCB, &sc, threadID);
|
||||
device->BindConstantBuffer(CS, sortCB, CB_GETBINDSLOT(SortConstants), threadID);
|
||||
device->UpdateBuffer(sortCB.get(), &sc, threadID);
|
||||
device->BindConstantBuffer(CS, sortCB.get(), CB_GETBINDSLOT(SortConstants), threadID);
|
||||
|
||||
device->Dispatch(numThreadGroups, 1, 1, threadID);
|
||||
device->UAVBarrier(uavs, ARRAYSIZE(uavs), threadID);
|
||||
|
||||
@@ -489,25 +489,25 @@ namespace wiGraphicsTypes
|
||||
};
|
||||
struct GraphicsPSODesc
|
||||
{
|
||||
VertexShader* vs = nullptr;
|
||||
PixelShader* ps = nullptr;
|
||||
HullShader* hs = nullptr;
|
||||
DomainShader* ds = nullptr;
|
||||
GeometryShader* gs = nullptr;
|
||||
BlendState* bs = nullptr;
|
||||
RasterizerState* rs = nullptr;
|
||||
DepthStencilState* dss = nullptr;
|
||||
VertexLayout* il = nullptr;
|
||||
PRIMITIVETOPOLOGY pt = TRIANGLELIST;
|
||||
UINT numRTs = 0;
|
||||
FORMAT RTFormats[8] = {};
|
||||
FORMAT DSFormat = FORMAT_UNKNOWN;
|
||||
SampleDesc sampleDesc;
|
||||
UINT sampleMask = 0xFFFFFFFF;
|
||||
const VertexShader* vs = nullptr;
|
||||
const PixelShader* ps = nullptr;
|
||||
const HullShader* hs = nullptr;
|
||||
const DomainShader* ds = nullptr;
|
||||
const GeometryShader* gs = nullptr;
|
||||
const BlendState* bs = nullptr;
|
||||
const RasterizerState* rs = nullptr;
|
||||
const DepthStencilState* dss = nullptr;
|
||||
const VertexLayout* il = nullptr;
|
||||
PRIMITIVETOPOLOGY pt = TRIANGLELIST;
|
||||
UINT numRTs = 0;
|
||||
FORMAT RTFormats[8] = {};
|
||||
FORMAT DSFormat = FORMAT_UNKNOWN;
|
||||
SampleDesc sampleDesc;
|
||||
UINT sampleMask = 0xFFFFFFFF;
|
||||
};
|
||||
struct ComputePSODesc
|
||||
{
|
||||
ComputeShader* cs = nullptr;
|
||||
const ComputeShader* cs = nullptr;
|
||||
};
|
||||
struct IndirectDrawArgsInstanced
|
||||
{
|
||||
|
||||
@@ -18,10 +18,10 @@ using namespace wiGraphicsTypes;
|
||||
namespace wiSceneSystem
|
||||
{
|
||||
|
||||
static VertexShader *vs = nullptr;
|
||||
static PixelShader *ps[RENDERPASS_COUNT] = {};
|
||||
static PixelShader *ps_simplest = nullptr;
|
||||
static ComputeShader *cs_simulate = nullptr;
|
||||
static const VertexShader *vs = nullptr;
|
||||
static const PixelShader *ps[RENDERPASS_COUNT] = {};
|
||||
static const PixelShader *ps_simplest = nullptr;
|
||||
static const ComputeShader *cs_simulate = nullptr;
|
||||
static DepthStencilState dss_default, dss_equal, dss_rejectopaque_keeptransparent;
|
||||
static RasterizerState rs, ncrs, wirers;
|
||||
static BlendState bs[2];
|
||||
@@ -209,12 +209,12 @@ void wiHairParticle::LoadShaders()
|
||||
{
|
||||
std::string path = wiRenderer::GetShaderPath();
|
||||
|
||||
vs = static_cast<VertexShader*>(wiResourceManager::GetShaderManager().add(path + "hairparticleVS.cso", wiResourceManager::VERTEXSHADER));
|
||||
vs = static_cast<const VertexShader*>(wiResourceManager::GetShaderManager().add(path + "hairparticleVS.cso", wiResourceManager::VERTEXSHADER));
|
||||
|
||||
ps[RENDERPASS_DEPTHONLY] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "hairparticlePS_alphatestonly.cso", wiResourceManager::PIXELSHADER));
|
||||
ps[RENDERPASS_DEFERRED] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "hairparticlePS_deferred.cso", wiResourceManager::PIXELSHADER));
|
||||
ps[RENDERPASS_FORWARD] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "hairparticlePS_forward.cso", wiResourceManager::PIXELSHADER));
|
||||
ps[RENDERPASS_TILEDFORWARD] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "hairparticlePS_tiledforward.cso", wiResourceManager::PIXELSHADER));
|
||||
ps[RENDERPASS_DEPTHONLY] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "hairparticlePS_alphatestonly.cso", wiResourceManager::PIXELSHADER));
|
||||
ps[RENDERPASS_DEFERRED] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "hairparticlePS_deferred.cso", wiResourceManager::PIXELSHADER));
|
||||
ps[RENDERPASS_FORWARD] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "hairparticlePS_forward.cso", wiResourceManager::PIXELSHADER));
|
||||
ps[RENDERPASS_TILEDFORWARD] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "hairparticlePS_tiledforward.cso", wiResourceManager::PIXELSHADER));
|
||||
|
||||
|
||||
GraphicsDevice* device = wiRenderer::GetDevice();
|
||||
@@ -278,7 +278,7 @@ void wiHairParticle::LoadShaders()
|
||||
}
|
||||
}
|
||||
|
||||
ps_simplest = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "hairparticlePS_simplest.cso", wiResourceManager::PIXELSHADER));
|
||||
ps_simplest = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "hairparticlePS_simplest.cso", wiResourceManager::PIXELSHADER));
|
||||
|
||||
{
|
||||
GraphicsPSODesc desc;
|
||||
@@ -293,7 +293,7 @@ void wiHairParticle::LoadShaders()
|
||||
device->CreateGraphicsPSO(&desc, &PSO_wire);
|
||||
}
|
||||
|
||||
cs_simulate = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "hairparticle_simulateCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
cs_simulate = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "hairparticle_simulateCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
|
||||
{
|
||||
ComputePSODesc desc;
|
||||
|
||||
+48
-48
@@ -39,21 +39,21 @@ namespace wiImage
|
||||
IMAGE_SAMPLING_COUNT,
|
||||
};
|
||||
|
||||
GPUBuffer constantBuffer;
|
||||
GPUBuffer processCb;
|
||||
VertexShader* vertexShader = nullptr;
|
||||
VertexShader* screenVS = nullptr;
|
||||
PixelShader* imagePS[IMAGE_SHADER_COUNT][IMAGE_SAMPLING_COUNT];
|
||||
PixelShader* postprocessPS[wiImageParams::PostProcess::POSTPROCESS_COUNT];
|
||||
PixelShader* deferredPS = nullptr;
|
||||
BlendState blendStates[BLENDMODE_COUNT];
|
||||
RasterizerState rasterizerState;
|
||||
DepthStencilState depthStencilStates[STENCILMODE_COUNT];
|
||||
BlendState blendStateDisableColor;
|
||||
DepthStencilState depthStencilStateDepthWrite;
|
||||
GraphicsPSO imagePSO[IMAGE_SHADER_COUNT][BLENDMODE_COUNT][STENCILMODE_COUNT][IMAGE_HDR_COUNT][IMAGE_SAMPLING_COUNT];
|
||||
GraphicsPSO postprocessPSO[wiImageParams::PostProcess::POSTPROCESS_COUNT];
|
||||
GraphicsPSO deferredPSO;
|
||||
GPUBuffer constantBuffer;
|
||||
GPUBuffer processCb;
|
||||
const VertexShader* vertexShader = nullptr;
|
||||
const VertexShader* screenVS = nullptr;
|
||||
const PixelShader* imagePS[IMAGE_SHADER_COUNT][IMAGE_SAMPLING_COUNT];
|
||||
const PixelShader* postprocessPS[wiImageParams::PostProcess::POSTPROCESS_COUNT];
|
||||
const PixelShader* deferredPS = nullptr;
|
||||
BlendState blendStates[BLENDMODE_COUNT];
|
||||
RasterizerState rasterizerState;
|
||||
DepthStencilState depthStencilStates[STENCILMODE_COUNT];
|
||||
BlendState blendStateDisableColor;
|
||||
DepthStencilState depthStencilStateDepthWrite;
|
||||
GraphicsPSO imagePSO[IMAGE_SHADER_COUNT][BLENDMODE_COUNT][STENCILMODE_COUNT][IMAGE_HDR_COUNT][IMAGE_SAMPLING_COUNT];
|
||||
GraphicsPSO postprocessPSO[wiImageParams::PostProcess::POSTPROCESS_COUNT];
|
||||
GraphicsPSO deferredPSO;
|
||||
|
||||
std::atomic_bool initialized = false;
|
||||
|
||||
@@ -358,43 +358,43 @@ namespace wiImage
|
||||
{
|
||||
std::string path = wiRenderer::GetShaderPath();
|
||||
|
||||
vertexShader = static_cast<VertexShader*>(wiResourceManager::GetShaderManager().add(path + "imageVS.cso", wiResourceManager::VERTEXSHADER));
|
||||
screenVS = static_cast<VertexShader*>(wiResourceManager::GetShaderManager().add(path + "screenVS.cso", wiResourceManager::VERTEXSHADER));
|
||||
vertexShader = static_cast<const VertexShader*>(wiResourceManager::GetShaderManager().add(path + "imageVS.cso", wiResourceManager::VERTEXSHADER));
|
||||
screenVS = static_cast<const VertexShader*>(wiResourceManager::GetShaderManager().add(path + "screenVS.cso", wiResourceManager::VERTEXSHADER));
|
||||
|
||||
imagePS[IMAGE_SHADER_STANDARD][IMAGE_SAMPLING_SIMPLE] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "imagePS.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_SEPARATENORMALMAP][IMAGE_SAMPLING_SIMPLE] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "imagePS_separatenormalmap.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_DISTORTION][IMAGE_SAMPLING_SIMPLE] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "imagePS_distortion.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_DISTORTION_MASKED][IMAGE_SAMPLING_SIMPLE] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "imagePS_distortion_masked.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_MASKED][IMAGE_SAMPLING_SIMPLE] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "imagePS_masked.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_FULLSCREEN][IMAGE_SAMPLING_SIMPLE] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "screenPS.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_STANDARD][IMAGE_SAMPLING_SIMPLE] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "imagePS.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_SEPARATENORMALMAP][IMAGE_SAMPLING_SIMPLE] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "imagePS_separatenormalmap.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_DISTORTION][IMAGE_SAMPLING_SIMPLE] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "imagePS_distortion.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_DISTORTION_MASKED][IMAGE_SAMPLING_SIMPLE] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "imagePS_distortion_masked.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_MASKED][IMAGE_SAMPLING_SIMPLE] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "imagePS_masked.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_FULLSCREEN][IMAGE_SAMPLING_SIMPLE] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "screenPS.cso", wiResourceManager::PIXELSHADER));
|
||||
|
||||
imagePS[IMAGE_SHADER_STANDARD][IMAGE_SAMPLING_BICUBIC] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "imagePS_bicubic.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_SEPARATENORMALMAP][IMAGE_SAMPLING_BICUBIC] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "imagePS_separatenormalmap_bicubic.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_DISTORTION][IMAGE_SAMPLING_BICUBIC] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "imagePS_distortion_bicubic.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_DISTORTION_MASKED][IMAGE_SAMPLING_BICUBIC] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "imagePS_distortion_masked_bicubic.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_MASKED][IMAGE_SAMPLING_BICUBIC] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "imagePS_masked_bicubic.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_FULLSCREEN][IMAGE_SAMPLING_BICUBIC] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "screenPS_bicubic.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_STANDARD][IMAGE_SAMPLING_BICUBIC] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "imagePS_bicubic.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_SEPARATENORMALMAP][IMAGE_SAMPLING_BICUBIC] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "imagePS_separatenormalmap_bicubic.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_DISTORTION][IMAGE_SAMPLING_BICUBIC] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "imagePS_distortion_bicubic.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_DISTORTION_MASKED][IMAGE_SAMPLING_BICUBIC] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "imagePS_distortion_masked_bicubic.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_MASKED][IMAGE_SAMPLING_BICUBIC] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "imagePS_masked_bicubic.cso", wiResourceManager::PIXELSHADER));
|
||||
imagePS[IMAGE_SHADER_FULLSCREEN][IMAGE_SAMPLING_BICUBIC] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "screenPS_bicubic.cso", wiResourceManager::PIXELSHADER));
|
||||
|
||||
postprocessPS[wiImageParams::PostProcess::BLUR] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "blurPS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::LIGHTSHAFT] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "lightShaftPS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::OUTLINE] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "outlinePS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::DEPTHOFFIELD] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "depthofFieldPS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::MOTIONBLUR] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "motionBlurPS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::BLOOMSEPARATE] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "bloomSeparatePS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::FXAA] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "fxaa.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::SSAO] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "ssao.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::SSSS] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "ssss.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::LINEARDEPTH] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "linDepthPS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::COLORGRADE] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "colorGradePS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::SSR] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "ssr.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::STEREOGRAM] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "stereogramPS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::TONEMAP] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "toneMapPS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::REPROJECTDEPTHBUFFER] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "reprojectDepthBufferPS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::DOWNSAMPLEDEPTHBUFFER] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "downsampleDepthBuffer4xPS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::TEMPORALAA] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "temporalAAResolvePS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::SHARPEN] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "sharpenPS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::BLUR] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "blurPS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::LIGHTSHAFT] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "lightShaftPS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::OUTLINE] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "outlinePS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::DEPTHOFFIELD] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "depthofFieldPS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::MOTIONBLUR] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "motionBlurPS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::BLOOMSEPARATE] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "bloomSeparatePS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::FXAA] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "fxaa.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::SSAO] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "ssao.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::SSSS] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "ssss.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::LINEARDEPTH] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "linDepthPS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::COLORGRADE] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "colorGradePS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::SSR] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "ssr.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::STEREOGRAM] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "stereogramPS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::TONEMAP] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "toneMapPS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::REPROJECTDEPTHBUFFER] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "reprojectDepthBufferPS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::DOWNSAMPLEDEPTHBUFFER] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "downsampleDepthBuffer4xPS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::TEMPORALAA] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "temporalAAResolvePS.cso", wiResourceManager::PIXELSHADER));
|
||||
postprocessPS[wiImageParams::PostProcess::SHARPEN] = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "sharpenPS.cso", wiResourceManager::PIXELSHADER));
|
||||
|
||||
deferredPS = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "deferredPS.cso", wiResourceManager::PIXELSHADER));
|
||||
deferredPS = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "deferredPS.cso", wiResourceManager::PIXELSHADER));
|
||||
|
||||
|
||||
GraphicsDevice* device = wiRenderer::GetDevice();
|
||||
|
||||
@@ -124,6 +124,10 @@ bool AABB::intersects(const RAY& ray) const {
|
||||
|
||||
return tmax >= tmin;
|
||||
}
|
||||
bool AABB::intersects(const SPHERE& sphere) const
|
||||
{
|
||||
return sphere.intersects(*this);
|
||||
}
|
||||
AABB AABB::operator* (float a)
|
||||
{
|
||||
XMFLOAT3 min = getMin();
|
||||
|
||||
@@ -33,6 +33,7 @@ struct AABB
|
||||
INTERSECTION_TYPE intersects(const AABB& b) const;
|
||||
bool intersects(const XMFLOAT3& p) const;
|
||||
bool intersects(const RAY& ray) const;
|
||||
bool intersects(const SPHERE& sphere) const;
|
||||
AABB operator* (float a);
|
||||
static AABB Merge(const AABB& a, const AABB& b);
|
||||
|
||||
|
||||
@@ -0,0 +1,283 @@
|
||||
#include "wiIntersect_BindLua.h"
|
||||
#include "Vector_BindLua.h"
|
||||
|
||||
namespace wiIntersect_BindLua
|
||||
{
|
||||
void Bind()
|
||||
{
|
||||
static bool initialized = false;
|
||||
if (!initialized)
|
||||
{
|
||||
initialized = true;
|
||||
|
||||
lua_State* L = wiLua::GetGlobal()->GetLuaState();
|
||||
|
||||
Luna<Ray_BindLua>::Register(L);
|
||||
Luna<AABB_BindLua>::Register(L);
|
||||
Luna<Sphere_BindLua>::Register(L);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const char Ray_BindLua::className[] = "Ray";
|
||||
|
||||
Luna<Ray_BindLua>::FunctionType Ray_BindLua::methods[] = {
|
||||
lunamethod(Ray_BindLua, Intersects),
|
||||
lunamethod(Ray_BindLua, GetOrigin),
|
||||
lunamethod(Ray_BindLua, GetDirection),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<Ray_BindLua>::PropertyType Ray_BindLua::properties[] = {
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
Ray_BindLua::Ray_BindLua(lua_State *L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 1)
|
||||
{
|
||||
Vector_BindLua* o = Luna<Vector_BindLua>::lightcheck(L, 1);
|
||||
Vector_BindLua* d = Luna<Vector_BindLua>::lightcheck(L, 2);
|
||||
if (o && d)
|
||||
{
|
||||
ray = RAY(o->vector, d->vector);
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "Ray(Vector origin,direction) requires two arguments of Vector type!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "Ray(Vector origin,direction) not enough arguments!");
|
||||
}
|
||||
}
|
||||
Ray_BindLua::~Ray_BindLua()
|
||||
{
|
||||
}
|
||||
|
||||
int Ray_BindLua::Intersects(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
AABB_BindLua* aabb = Luna<AABB_BindLua>::lightcheck(L, 1);
|
||||
if (aabb)
|
||||
{
|
||||
bool intersects = ray.intersects(aabb->aabb);
|
||||
wiLua::SSetBool(L, intersects);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Sphere_BindLua* sphere = Luna<Sphere_BindLua>::lightcheck(L, 1);
|
||||
if (sphere)
|
||||
{
|
||||
bool intersects = ray.intersects(sphere->sphere);
|
||||
wiLua::SSetBool(L, intersects);
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
wiLua::SError(L, "[Intersects(AABB), Intersects(Sphere)] no matching arguments! ");
|
||||
return 0;
|
||||
}
|
||||
int Ray_BindLua::GetOrigin(lua_State* L)
|
||||
{
|
||||
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&ray.origin)));
|
||||
return 1;
|
||||
}
|
||||
int Ray_BindLua::GetDirection(lua_State* L)
|
||||
{
|
||||
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&ray.direction)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char AABB_BindLua::className[] = "AABB";
|
||||
|
||||
Luna<AABB_BindLua>::FunctionType AABB_BindLua::methods[] = {
|
||||
lunamethod(AABB_BindLua, Intersects),
|
||||
lunamethod(AABB_BindLua, GetMin),
|
||||
lunamethod(AABB_BindLua, GetMax),
|
||||
lunamethod(AABB_BindLua, GetCenter),
|
||||
lunamethod(AABB_BindLua, GetHalfExtents),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<AABB_BindLua>::PropertyType AABB_BindLua::properties[] = {
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
AABB_BindLua::AABB_BindLua(lua_State *L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 1)
|
||||
{
|
||||
Vector_BindLua* _minV = Luna<Vector_BindLua>::lightcheck(L, 1);
|
||||
Vector_BindLua* _maxV = Luna<Vector_BindLua>::lightcheck(L, 2);
|
||||
if (_minV && _maxV)
|
||||
{
|
||||
XMFLOAT3 _min, _max;
|
||||
XMStoreFloat3(&_min, _minV->vector);
|
||||
XMStoreFloat3(&_max, _maxV->vector);
|
||||
|
||||
aabb = AABB(_min, _max);
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "AABB(Vector min,max) requires two arguments of Vector type!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "AABB(Vector min,max) not enough arguments!");
|
||||
}
|
||||
}
|
||||
AABB_BindLua::~AABB_BindLua()
|
||||
{
|
||||
}
|
||||
|
||||
int AABB_BindLua::Intersects(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
AABB_BindLua* _aabb = Luna<AABB_BindLua>::lightcheck(L, 1);
|
||||
if (_aabb)
|
||||
{
|
||||
int intersects = (int)aabb.intersects(_aabb->aabb);
|
||||
wiLua::SSetInt(L, intersects);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Sphere_BindLua* _sphere = Luna<Sphere_BindLua>::lightcheck(L, 1);
|
||||
if (_sphere)
|
||||
{
|
||||
bool intersects = aabb.intersects(_sphere->sphere);
|
||||
wiLua::SSetBool(L, intersects);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Ray_BindLua* ray = Luna<Ray_BindLua>::lightcheck(L, 1);
|
||||
if (ray)
|
||||
{
|
||||
bool intersects = ray->ray.intersects(aabb);
|
||||
wiLua::SSetBool(L, intersects);
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
wiLua::SError(L, "[Intersects(AABB), Intersects(Sphere), Intersects(Ray)] no matching arguments! ");
|
||||
return 0;
|
||||
}
|
||||
int AABB_BindLua::GetMin(lua_State* L)
|
||||
{
|
||||
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&aabb.getMin())));
|
||||
return 1;
|
||||
}
|
||||
int AABB_BindLua::GetMax(lua_State* L)
|
||||
{
|
||||
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&aabb.getMax())));
|
||||
return 1;
|
||||
}
|
||||
int AABB_BindLua::GetCenter(lua_State* L)
|
||||
{
|
||||
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&aabb.getCenter())));
|
||||
return 1;
|
||||
}
|
||||
int AABB_BindLua::GetHalfExtents(lua_State* L)
|
||||
{
|
||||
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&aabb.getHalfWidth())));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char Sphere_BindLua::className[] = "Sphere";
|
||||
|
||||
Luna<Sphere_BindLua>::FunctionType Sphere_BindLua::methods[] = {
|
||||
lunamethod(Sphere_BindLua, Intersects),
|
||||
lunamethod(Sphere_BindLua, GetCenter),
|
||||
lunamethod(Sphere_BindLua, GetRadius),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<Sphere_BindLua>::PropertyType Sphere_BindLua::properties[] = {
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
Sphere_BindLua::Sphere_BindLua(lua_State *L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 1)
|
||||
{
|
||||
Vector_BindLua* cV = Luna<Vector_BindLua>::lightcheck(L, 1);
|
||||
if (cV)
|
||||
{
|
||||
XMFLOAT3 c;
|
||||
XMStoreFloat3(&c, cV->vector);
|
||||
|
||||
float r = wiLua::SGetFloat(L, 2);
|
||||
|
||||
sphere = SPHERE(c, r);
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "Sphere(Vector center, float radius) requires first argument to be of Vector type!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "Sphere(Vector center, float radius) not enough arguments!");
|
||||
}
|
||||
}
|
||||
Sphere_BindLua::~Sphere_BindLua()
|
||||
{
|
||||
}
|
||||
|
||||
int Sphere_BindLua::Intersects(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
AABB_BindLua* _aabb = Luna<AABB_BindLua>::lightcheck(L, 1);
|
||||
if (_aabb)
|
||||
{
|
||||
bool intersects = sphere.intersects(_aabb->aabb);
|
||||
wiLua::SSetInt(L, intersects);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Sphere_BindLua* _sphere = Luna<Sphere_BindLua>::lightcheck(L, 1);
|
||||
if (_sphere)
|
||||
{
|
||||
bool intersects = sphere.intersects(_sphere->sphere);
|
||||
wiLua::SSetBool(L, intersects);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Ray_BindLua* ray = Luna<Ray_BindLua>::lightcheck(L, 1);
|
||||
if (ray)
|
||||
{
|
||||
bool intersects = ray->ray.intersects(sphere);
|
||||
wiLua::SSetBool(L, intersects);
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
wiLua::SError(L, "[Intersects(AABB), Intersects(Sphere), Intersects(Ray)] no matching arguments! ");
|
||||
return 0;
|
||||
}
|
||||
int Sphere_BindLua::GetCenter(lua_State* L)
|
||||
{
|
||||
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&sphere.center)));
|
||||
return 1;
|
||||
}
|
||||
int Sphere_BindLua::GetRadius(lua_State* L)
|
||||
{
|
||||
wiLua::SSetFloat(L, sphere.radius);
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
#include "wiLua.h"
|
||||
#include "wiLuna.h"
|
||||
#include "wiIntersect.h"
|
||||
|
||||
namespace wiIntersect_BindLua
|
||||
{
|
||||
void Bind();
|
||||
|
||||
|
||||
class Ray_BindLua
|
||||
{
|
||||
public:
|
||||
RAY ray;
|
||||
|
||||
static const char className[];
|
||||
static Luna<Ray_BindLua>::FunctionType methods[];
|
||||
static Luna<Ray_BindLua>::PropertyType properties[];
|
||||
|
||||
Ray_BindLua(const RAY& ray) : ray(ray) {}
|
||||
Ray_BindLua(lua_State *L);
|
||||
~Ray_BindLua();
|
||||
|
||||
int Intersects(lua_State* L);
|
||||
int GetOrigin(lua_State* L);
|
||||
int GetDirection(lua_State* L);
|
||||
};
|
||||
|
||||
class AABB_BindLua
|
||||
{
|
||||
public:
|
||||
AABB aabb;
|
||||
|
||||
static const char className[];
|
||||
static Luna<AABB_BindLua>::FunctionType methods[];
|
||||
static Luna<AABB_BindLua>::PropertyType properties[];
|
||||
|
||||
AABB_BindLua(const AABB& aabb) : aabb(aabb) {}
|
||||
AABB_BindLua(lua_State *L);
|
||||
~AABB_BindLua();
|
||||
|
||||
int Intersects(lua_State* L);
|
||||
int GetMin(lua_State* L);
|
||||
int GetMax(lua_State* L);
|
||||
int GetCenter(lua_State* L);
|
||||
int GetHalfExtents(lua_State* L);
|
||||
};
|
||||
|
||||
class Sphere_BindLua
|
||||
{
|
||||
public:
|
||||
SPHERE sphere;
|
||||
|
||||
static const char className[];
|
||||
static Luna<Sphere_BindLua>::FunctionType methods[];
|
||||
static Luna<Sphere_BindLua>::PropertyType properties[];
|
||||
|
||||
Sphere_BindLua(const SPHERE& sphere) : sphere(sphere) {}
|
||||
Sphere_BindLua(lua_State *L);
|
||||
~Sphere_BindLua();
|
||||
|
||||
int Intersects(lua_State* L);
|
||||
int GetCenter(lua_State* L);
|
||||
int GetRadius(lua_State* L);
|
||||
};
|
||||
}
|
||||
@@ -9,11 +9,11 @@ using namespace wiGraphicsTypes;
|
||||
|
||||
namespace wiLensFlare
|
||||
{
|
||||
static GPUBuffer *constantBuffer = nullptr;
|
||||
static PixelShader *pixelShader = nullptr;
|
||||
static GeometryShader *geometryShader = nullptr;
|
||||
static VertexShader *vertexShader = nullptr;
|
||||
static Sampler *samplercmp = nullptr;
|
||||
static std::unique_ptr<GPUBuffer> constantBuffer;
|
||||
static const PixelShader *pixelShader = nullptr;
|
||||
static const GeometryShader *geometryShader = nullptr;
|
||||
static const VertexShader *vertexShader = nullptr;
|
||||
static Sampler samplercmp;
|
||||
static RasterizerState rasterizerState;
|
||||
static DepthStencilState depthStencilState;
|
||||
static BlendState blendState;
|
||||
@@ -32,8 +32,8 @@ namespace wiLensFlare
|
||||
XMStoreFloat4(&cb.xSunPos, lightPos / XMVectorSet((float)wiRenderer::GetInternalResolution().x, (float)wiRenderer::GetInternalResolution().y, 1, 1));
|
||||
cb.xScreen = XMFLOAT4((float)wiRenderer::GetInternalResolution().x, (float)wiRenderer::GetInternalResolution().y, 0, 0);
|
||||
|
||||
device->UpdateBuffer(constantBuffer, &cb, threadID);
|
||||
device->BindConstantBuffer(GS, constantBuffer, CB_GETBINDSLOT(LensFlareCB), threadID);
|
||||
device->UpdateBuffer(constantBuffer.get(), &cb, threadID);
|
||||
device->BindConstantBuffer(GS, constantBuffer.get(), CB_GETBINDSLOT(LensFlareCB), threadID);
|
||||
|
||||
|
||||
int i = 0;
|
||||
@@ -47,7 +47,7 @@ namespace wiLensFlare
|
||||
}
|
||||
}
|
||||
|
||||
device->BindSampler(GS, samplercmp, SSLOT_ONDEMAND0, threadID);
|
||||
device->BindSampler(GS, &samplercmp, SSLOT_ONDEMAND0, threadID);
|
||||
|
||||
|
||||
device->Draw(i, 0, threadID);
|
||||
@@ -61,11 +61,11 @@ namespace wiLensFlare
|
||||
{
|
||||
std::string path = wiRenderer::GetShaderPath();
|
||||
|
||||
vertexShader = static_cast<VertexShader*>(wiResourceManager::GetShaderManager().add(path + "lensFlareVS.cso", wiResourceManager::VERTEXSHADER));
|
||||
vertexShader = static_cast<const VertexShader*>(wiResourceManager::GetShaderManager().add(path + "lensFlareVS.cso", wiResourceManager::VERTEXSHADER));
|
||||
|
||||
pixelShader = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "lensFlarePS.cso", wiResourceManager::PIXELSHADER));
|
||||
pixelShader = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "lensFlarePS.cso", wiResourceManager::PIXELSHADER));
|
||||
|
||||
geometryShader = static_cast<GeometryShader*>(wiResourceManager::GetShaderManager().add(path + "lensFlareGS.cso", wiResourceManager::GEOMETRYSHADER));
|
||||
geometryShader = static_cast<const GeometryShader*>(wiResourceManager::GetShaderManager().add(path + "lensFlareGS.cso", wiResourceManager::GEOMETRYSHADER));
|
||||
|
||||
|
||||
GraphicsDevice* device = wiRenderer::GetDevice();
|
||||
@@ -90,8 +90,8 @@ namespace wiLensFlare
|
||||
bd.ByteWidth = sizeof(LensFlareCB);
|
||||
bd.BindFlags = BIND_CONSTANT_BUFFER;
|
||||
bd.CPUAccessFlags = CPU_ACCESS_WRITE;
|
||||
constantBuffer = new GPUBuffer;
|
||||
wiRenderer::GetDevice()->CreateBuffer(&bd, nullptr, constantBuffer);
|
||||
constantBuffer.reset(new GPUBuffer);
|
||||
wiRenderer::GetDevice()->CreateBuffer(&bd, nullptr, constantBuffer.get());
|
||||
|
||||
|
||||
RasterizerStateDesc rs;
|
||||
@@ -157,8 +157,7 @@ namespace wiLensFlare
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 0;
|
||||
samplerDesc.ComparisonFunc = COMPARISON_GREATER_EQUAL;
|
||||
samplercmp = new Sampler;
|
||||
wiRenderer::GetDevice()->CreateSamplerState(&samplerDesc, samplercmp);
|
||||
wiRenderer::GetDevice()->CreateSamplerState(&samplerDesc, &samplercmp);
|
||||
}
|
||||
|
||||
|
||||
@@ -167,12 +166,8 @@ namespace wiLensFlare
|
||||
|
||||
wiBackLog::post("wiLensFlare Initialized");
|
||||
}
|
||||
void CleanUp() {
|
||||
SAFE_DELETE(constantBuffer);
|
||||
SAFE_DELETE(pixelShader);
|
||||
SAFE_DELETE(geometryShader);
|
||||
SAFE_DELETE(vertexShader);
|
||||
SAFE_DELETE(samplercmp);
|
||||
void CleanUp()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "wiFont_BindLua.h"
|
||||
#include "wiBackLog_BindLua.h"
|
||||
#include "wiNetwork_BindLua.h"
|
||||
#include "wiIntersect_BindLua.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
@@ -78,6 +79,7 @@ wiLua* wiLua::GetGlobal()
|
||||
wiBackLog_BindLua::Bind();
|
||||
wiClient_BindLua::Bind();
|
||||
wiServer_BindLua::Bind();
|
||||
wiIntersect_BindLua::Bind();
|
||||
|
||||
}
|
||||
return globalLua;
|
||||
|
||||
+12
-12
@@ -11,12 +11,12 @@ using namespace wiSceneSystem;
|
||||
|
||||
namespace wiOcean_Internal
|
||||
{
|
||||
ComputeShader* m_pUpdateSpectrumCS = nullptr;
|
||||
ComputeShader* m_pUpdateDisplacementMapCS = nullptr;
|
||||
ComputeShader* m_pUpdateGradientFoldingCS = nullptr;
|
||||
VertexShader* g_pOceanSurfVS = nullptr;
|
||||
PixelShader* g_pWireframePS = nullptr;
|
||||
PixelShader* g_pOceanSurfPS = nullptr;
|
||||
const ComputeShader* m_pUpdateSpectrumCS = nullptr;
|
||||
const ComputeShader* m_pUpdateDisplacementMapCS = nullptr;
|
||||
const ComputeShader* m_pUpdateGradientFoldingCS = nullptr;
|
||||
const VertexShader* g_pOceanSurfVS = nullptr;
|
||||
const PixelShader* g_pWireframePS = nullptr;
|
||||
const PixelShader* g_pOceanSurfPS = nullptr;
|
||||
|
||||
GPUBuffer g_pShadingCB;
|
||||
RasterizerState rasterizerState;
|
||||
@@ -367,15 +367,15 @@ void wiOcean::LoadShaders()
|
||||
|
||||
std::string path = wiRenderer::GetShaderPath();
|
||||
|
||||
m_pUpdateSpectrumCS = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "oceanSimulatorCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
m_pUpdateDisplacementMapCS = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "oceanUpdateDisplacementMapCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
m_pUpdateGradientFoldingCS = static_cast<ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "oceanUpdateGradientFoldingCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
m_pUpdateSpectrumCS = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "oceanSimulatorCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
m_pUpdateDisplacementMapCS = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "oceanUpdateDisplacementMapCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
m_pUpdateGradientFoldingCS = static_cast<const ComputeShader*>(wiResourceManager::GetShaderManager().add(path + "oceanUpdateGradientFoldingCS.cso", wiResourceManager::COMPUTESHADER));
|
||||
|
||||
|
||||
g_pOceanSurfVS = static_cast<VertexShader*>(wiResourceManager::GetShaderManager().add(path + "oceanSurfaceVS.cso", wiResourceManager::VERTEXSHADER));
|
||||
g_pOceanSurfVS = static_cast<const VertexShader*>(wiResourceManager::GetShaderManager().add(path + "oceanSurfaceVS.cso", wiResourceManager::VERTEXSHADER));
|
||||
|
||||
g_pOceanSurfPS = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "oceanSurfacePS.cso", wiResourceManager::PIXELSHADER));
|
||||
g_pWireframePS = static_cast<PixelShader*>(wiResourceManager::GetShaderManager().add(path + "oceanSurfaceSimplePS.cso", wiResourceManager::PIXELSHADER));
|
||||
g_pOceanSurfPS = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "oceanSurfacePS.cso", wiResourceManager::PIXELSHADER));
|
||||
g_pWireframePS = static_cast<const PixelShader*>(wiResourceManager::GetShaderManager().add(path + "oceanSurfaceSimplePS.cso", wiResourceManager::PIXELSHADER));
|
||||
|
||||
|
||||
GraphicsDevice* device = wiRenderer::GetDevice();
|
||||
|
||||
+188
-212
File diff suppressed because it is too large
Load Diff
+13
-13
@@ -32,19 +32,19 @@ namespace wiRenderer
|
||||
static const wiGraphicsTypes::FORMAT DSFormat_small = wiGraphicsTypes::FORMAT_D16_UNORM;
|
||||
static const wiGraphicsTypes::FORMAT DSFormat_small_alias = wiGraphicsTypes::FORMAT_R16_TYPELESS;
|
||||
|
||||
wiGraphicsTypes::Sampler* GetSampler(int slot);
|
||||
wiGraphicsTypes::VertexShader* GetVertexShader(VSTYPES id);
|
||||
wiGraphicsTypes::HullShader* GetHullShader(VSTYPES id);
|
||||
wiGraphicsTypes::DomainShader* GetDomainShader(VSTYPES id);
|
||||
wiGraphicsTypes::GeometryShader* GetGeometryShader(VSTYPES id);
|
||||
wiGraphicsTypes::PixelShader* GetPixelShader(PSTYPES id);
|
||||
wiGraphicsTypes::ComputeShader* GetComputeShader(PSTYPES id);
|
||||
wiGraphicsTypes::VertexLayout* GetVertexLayout(VLTYPES id);
|
||||
wiGraphicsTypes::RasterizerState* GetRasterizerState(RSTYPES id);
|
||||
wiGraphicsTypes::DepthStencilState* GetDepthStencilState(DSSTYPES id);
|
||||
wiGraphicsTypes::BlendState* GetBlendState(BSTYPES id);
|
||||
wiGraphicsTypes::GPUBuffer* GetConstantBuffer(CBTYPES id);
|
||||
wiGraphicsTypes::Texture* GetTexture(TEXTYPES id);
|
||||
const wiGraphicsTypes::Sampler* GetSampler(int slot);
|
||||
const wiGraphicsTypes::VertexShader* GetVertexShader(VSTYPES id);
|
||||
const wiGraphicsTypes::HullShader* GetHullShader(VSTYPES id);
|
||||
const wiGraphicsTypes::DomainShader* GetDomainShader(VSTYPES id);
|
||||
const wiGraphicsTypes::GeometryShader* GetGeometryShader(VSTYPES id);
|
||||
const wiGraphicsTypes::PixelShader* GetPixelShader(PSTYPES id);
|
||||
const wiGraphicsTypes::ComputeShader* GetComputeShader(PSTYPES id);
|
||||
const wiGraphicsTypes::VertexLayout* GetVertexLayout(VLTYPES id);
|
||||
const wiGraphicsTypes::RasterizerState* GetRasterizerState(RSTYPES id);
|
||||
const wiGraphicsTypes::DepthStencilState* GetDepthStencilState(DSSTYPES id);
|
||||
const wiGraphicsTypes::BlendState* GetBlendState(BSTYPES id);
|
||||
const wiGraphicsTypes::GPUBuffer* GetConstantBuffer(CBTYPES id);
|
||||
const wiGraphicsTypes::Texture* GetTexture(TEXTYPES id);
|
||||
|
||||
void ModifySampler(const wiGraphicsTypes::SamplerDesc& desc, int slot);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "wiHelper.h"
|
||||
#include "wiSceneSystem.h"
|
||||
#include "wiSceneSystem_BindLua.h"
|
||||
#include "wiIntersect_BindLua.h"
|
||||
#include "Vector_BindLua.h"
|
||||
#include "Matrix_BindLua.h"
|
||||
#include "Texture_BindLua.h"
|
||||
@@ -14,6 +15,7 @@ using namespace wiECS;
|
||||
using namespace wiGraphicsTypes;
|
||||
using namespace wiSceneSystem;
|
||||
using namespace wiSceneSystem_BindLua;
|
||||
using namespace wiIntersect_BindLua;
|
||||
|
||||
namespace wiRenderer_BindLua
|
||||
{
|
||||
@@ -206,24 +208,6 @@ namespace wiRenderer_BindLua
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int SetPhysicsParams(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
assert(0);
|
||||
//wiRenderer::physicsEngine->rigidBodyPhysicsEnabled = wiLua::SGetBool(L, 1);
|
||||
//if (argc > 1)
|
||||
//{
|
||||
// wiRenderer::physicsEngine->softBodyPhysicsEnabled = wiLua::SGetBool(L, 2);
|
||||
// if (argc > 2)
|
||||
// {
|
||||
// wiRenderer::physicsEngine->softBodyIterationCount = wiLua::SGetInt(L, 3);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int SetResolution(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
@@ -264,35 +248,42 @@ namespace wiRenderer_BindLua
|
||||
return 0;
|
||||
}
|
||||
|
||||
//int Pick(lua_State* L)
|
||||
//{
|
||||
// int argc = wiLua::SGetArgCount(L);
|
||||
// if (argc > 0)
|
||||
// {
|
||||
// Ray_BindLua* ray = Luna<Ray_BindLua>::lightcheck(L, 1);
|
||||
// if (ray != nullptr)
|
||||
// {
|
||||
// UINT renderTypeMask = RENDERTYPE_OPAQUE;
|
||||
// uint32_t layerMask = 0xFFFFFFFF;
|
||||
// if (argc > 1)
|
||||
// {
|
||||
// renderTypeMask = (UINT)wiLua::SGetInt(L, 2);
|
||||
// if (argc > 2)
|
||||
// {
|
||||
// int mask = wiLua::SGetInt(L, 3);
|
||||
// layerMask = *reinterpret_cast<uint32_t*>(&mask);
|
||||
// }
|
||||
// }
|
||||
// auto& pick = wiRenderer::RayIntersectWorld(ray->ray, renderTypeMask, layerMask);
|
||||
// Luna<Object_BindLua>::push(L, new Object_BindLua(pick.object));
|
||||
// Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&pick.position)));
|
||||
// Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&pick.normal)));
|
||||
// wiLua::SSetFloat(L, pick.distance);
|
||||
// return 4;
|
||||
// }
|
||||
// }
|
||||
// return 0;
|
||||
//}
|
||||
int Pick(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
Ray_BindLua* ray = Luna<Ray_BindLua>::lightcheck(L, 1);
|
||||
if (ray != nullptr)
|
||||
{
|
||||
UINT renderTypeMask = RENDERTYPE_OPAQUE;
|
||||
uint32_t layerMask = 0xFFFFFFFF;
|
||||
if (argc > 1)
|
||||
{
|
||||
renderTypeMask = (UINT)wiLua::SGetInt(L, 2);
|
||||
if (argc > 2)
|
||||
{
|
||||
int mask = wiLua::SGetInt(L, 3);
|
||||
layerMask = *reinterpret_cast<uint32_t*>(&mask);
|
||||
}
|
||||
}
|
||||
auto& pick = wiRenderer::RayIntersectWorld(ray->ray, renderTypeMask, layerMask);
|
||||
wiLua::SSetInt(L, (int)pick.entity);
|
||||
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&pick.position)));
|
||||
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat3(&pick.normal)));
|
||||
wiLua::SSetFloat(L, pick.distance);
|
||||
return 4;
|
||||
}
|
||||
|
||||
wiLua::SError(L, "Pick(Ray ray, opt PICKTYPE pickType, opt uint layerMask) first argument must be of Vector type!");
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "Pick(Ray ray, opt PICKTYPE pickType, opt uint layerMask) not enough arguments!");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
int DrawLine(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
@@ -323,6 +314,69 @@ namespace wiRenderer_BindLua
|
||||
|
||||
return 0;
|
||||
}
|
||||
int DrawPoint(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
Vector_BindLua* a = Luna<Vector_BindLua>::lightcheck(L, 1);
|
||||
if (a)
|
||||
{
|
||||
wiRenderer::RenderablePoint point;
|
||||
XMStoreFloat3(&point.position, a->vector);
|
||||
if (argc > 1)
|
||||
{
|
||||
point.size = wiLua::SGetFloat(L, 2);
|
||||
|
||||
if (argc > 2)
|
||||
{
|
||||
Vector_BindLua* color = Luna<Vector_BindLua>::lightcheck(L, 3);
|
||||
XMStoreFloat4(&point.color, color->vector);
|
||||
}
|
||||
}
|
||||
wiRenderer::AddRenderablePoint(point);
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "DrawPoint(Vector origin, opt float size, opt Vector color) first argument must be a Vector type!");
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "DrawPoint(Vector origin, opt float size, opt Vector color) not enough arguments!");
|
||||
|
||||
return 0;
|
||||
}
|
||||
int DrawBox(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
Matrix_BindLua* m = Luna<Matrix_BindLua>::lightcheck(L, 1);
|
||||
if (m)
|
||||
{
|
||||
XMFLOAT4X4 mat;
|
||||
XMStoreFloat4x4(&mat, m->matrix);
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
Vector_BindLua* color = Luna<Vector_BindLua>::lightcheck(L, 2);
|
||||
if (color)
|
||||
{
|
||||
XMFLOAT4 col;
|
||||
XMStoreFloat4(&col, color->vector);
|
||||
wiRenderer::AddRenderableBox(mat, col);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
wiRenderer::AddRenderableBox(mat);
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "DrawBox(Matrix boxMatrix, opt Vector color) first argument must be a Matrix type!");
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "DrawBox(Matrix boxMatrix, opt Vector color) not enough arguments!");
|
||||
|
||||
return 0;
|
||||
}
|
||||
int PutWaterRipple(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
@@ -390,13 +444,14 @@ namespace wiRenderer_BindLua
|
||||
wiLua::GetGlobal()->RegisterFunc("SetDebugEmittersEnabled", SetDebugEmittersEnabled);
|
||||
wiLua::GetGlobal()->RegisterFunc("SetDebugForceFieldsEnabled", SetDebugForceFieldsEnabled);
|
||||
wiLua::GetGlobal()->RegisterFunc("SetVSyncEnabled", SetVSyncEnabled);
|
||||
wiLua::GetGlobal()->RegisterFunc("SetPhysicsParams", SetPhysicsParams);
|
||||
wiLua::GetGlobal()->RegisterFunc("SetResolution", SetResolution);
|
||||
wiLua::GetGlobal()->RegisterFunc("SetDebugLightCulling", SetDebugLightCulling);
|
||||
wiLua::GetGlobal()->RegisterFunc("SetOcclusionCullingEnabled", SetOcclusionCullingEnabled);
|
||||
|
||||
//wiLua::GetGlobal()->RegisterFunc("Pick", Pick);
|
||||
wiLua::GetGlobal()->RegisterFunc("Pick", Pick);
|
||||
wiLua::GetGlobal()->RegisterFunc("DrawLine", DrawLine);
|
||||
wiLua::GetGlobal()->RegisterFunc("DrawPoint", DrawPoint);
|
||||
wiLua::GetGlobal()->RegisterFunc("DrawBox", DrawBox);
|
||||
wiLua::GetGlobal()->RegisterFunc("PutWaterRipple", PutWaterRipple);
|
||||
|
||||
|
||||
|
||||
@@ -31,26 +31,26 @@ wiResourceManager& wiResourceManager::GetShaderManager()
|
||||
}
|
||||
|
||||
|
||||
const wiResourceManager::Resource* wiResourceManager::get(const wiHashString& name, bool incRefCount)
|
||||
wiResourceManager::Resource wiResourceManager::get(const wiHashString& name, bool incRefCount)
|
||||
{
|
||||
lock.lock();
|
||||
auto& it = resources.find(name);
|
||||
if (it != resources.end())
|
||||
{
|
||||
if(incRefCount)
|
||||
it->second->refCount++;
|
||||
it->second.refCount++;
|
||||
lock.unlock();
|
||||
return it->second;
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
return nullptr;
|
||||
return Resource();
|
||||
}
|
||||
|
||||
void* wiResourceManager::add(const wiHashString& name, Data_Type newType)
|
||||
const void* wiResourceManager::add(const wiHashString& name, Data_Type newType)
|
||||
{
|
||||
const Resource* res = get(name,true);
|
||||
if(!res)
|
||||
Resource res = get(name,true);
|
||||
if(res.type == EMPTY)
|
||||
{
|
||||
string nameStr = name.GetString();
|
||||
string ext = wiHelper::toUpper(nameStr.substr(nameStr.length() - 3, nameStr.length()));
|
||||
@@ -351,20 +351,24 @@ void* wiResourceManager::add(const wiHashString& name, Data_Type newType)
|
||||
if (success != nullptr)
|
||||
{
|
||||
lock.lock();
|
||||
resources.insert(pair<wiHashString, Resource*>(name, new Resource(success, type)));
|
||||
Resource resource;
|
||||
resource.data = success;
|
||||
resource.type = type;
|
||||
resource.refCount = 1;
|
||||
resources.insert(make_pair(name, resource));
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
return res->data;
|
||||
return res.data;
|
||||
}
|
||||
|
||||
bool wiResourceManager::del(const wiHashString& name, bool forceDelete)
|
||||
{
|
||||
lock.lock();
|
||||
Resource* res = nullptr;
|
||||
Resource res;
|
||||
auto& it = resources.find(name);
|
||||
if (it != resources.end())
|
||||
res = it->second;
|
||||
@@ -375,59 +379,60 @@ bool wiResourceManager::del(const wiHashString& name, bool forceDelete)
|
||||
}
|
||||
lock.unlock();
|
||||
|
||||
if(res && (res->refCount<=1 || forceDelete))
|
||||
if (res.data != nullptr && (res.refCount <= 1 || forceDelete))
|
||||
{
|
||||
lock.lock();
|
||||
bool success = true;
|
||||
|
||||
if(res->data)
|
||||
switch(res->type){
|
||||
case Data_Type::IMAGE_1D:
|
||||
SAFE_DELETE(reinterpret_cast<Texture1D*&>(res->data));
|
||||
break;
|
||||
case Data_Type::IMAGE_2D:
|
||||
SAFE_DELETE(reinterpret_cast<Texture2D*&>(res->data));
|
||||
break;
|
||||
case Data_Type::IMAGE_3D:
|
||||
SAFE_DELETE(reinterpret_cast<Texture3D*&>(res->data));
|
||||
break;
|
||||
case Data_Type::VERTEXSHADER:
|
||||
SAFE_DELETE(reinterpret_cast<VertexShader*&>(res->data));
|
||||
break;
|
||||
case Data_Type::PIXELSHADER:
|
||||
SAFE_DELETE(reinterpret_cast<PixelShader*&>(res->data));
|
||||
break;
|
||||
case Data_Type::GEOMETRYSHADER:
|
||||
SAFE_DELETE(reinterpret_cast<GeometryShader*&>(res->data));
|
||||
break;
|
||||
case Data_Type::HULLSHADER:
|
||||
SAFE_DELETE(reinterpret_cast<HullShader*&>(res->data));
|
||||
break;
|
||||
case Data_Type::DOMAINSHADER:
|
||||
SAFE_DELETE(reinterpret_cast<DomainShader*&>(res->data));
|
||||
break;
|
||||
case Data_Type::COMPUTESHADER:
|
||||
SAFE_DELETE(reinterpret_cast<ComputeShader*&>(res->data));
|
||||
break;
|
||||
case Data_Type::SOUND:
|
||||
case Data_Type::MUSIC:
|
||||
SAFE_DELETE(reinterpret_cast<wiSound*&>(res->data));
|
||||
break;
|
||||
default:
|
||||
success=false;
|
||||
break;
|
||||
};
|
||||
switch (res.type)
|
||||
{
|
||||
case Data_Type::IMAGE_1D:
|
||||
SAFE_DELETE(reinterpret_cast<const Texture1D*&>(res.data));
|
||||
break;
|
||||
case Data_Type::IMAGE_2D:
|
||||
SAFE_DELETE(reinterpret_cast<const Texture2D*&>(res.data));
|
||||
break;
|
||||
case Data_Type::IMAGE_3D:
|
||||
SAFE_DELETE(reinterpret_cast<const Texture3D*&>(res.data));
|
||||
break;
|
||||
case Data_Type::VERTEXSHADER:
|
||||
SAFE_DELETE(reinterpret_cast<const VertexShader*&>(res.data));
|
||||
break;
|
||||
case Data_Type::PIXELSHADER:
|
||||
SAFE_DELETE(reinterpret_cast<const PixelShader*&>(res.data));
|
||||
break;
|
||||
case Data_Type::GEOMETRYSHADER:
|
||||
SAFE_DELETE(reinterpret_cast<const GeometryShader*&>(res.data));
|
||||
break;
|
||||
case Data_Type::HULLSHADER:
|
||||
SAFE_DELETE(reinterpret_cast<const HullShader*&>(res.data));
|
||||
break;
|
||||
case Data_Type::DOMAINSHADER:
|
||||
SAFE_DELETE(reinterpret_cast<const DomainShader*&>(res.data));
|
||||
break;
|
||||
case Data_Type::COMPUTESHADER:
|
||||
SAFE_DELETE(reinterpret_cast<const ComputeShader*&>(res.data));
|
||||
break;
|
||||
case Data_Type::SOUND:
|
||||
case Data_Type::MUSIC:
|
||||
SAFE_DELETE(reinterpret_cast<const wiSound*&>(res.data));
|
||||
break;
|
||||
default:
|
||||
success = false;
|
||||
break;
|
||||
};
|
||||
|
||||
delete res;
|
||||
resources.erase(name);
|
||||
|
||||
lock.unlock();
|
||||
|
||||
return success;
|
||||
}
|
||||
else if (res)
|
||||
else if (res.data != nullptr)
|
||||
{
|
||||
res->refCount--;
|
||||
lock.lock();
|
||||
resources[name].refCount--;
|
||||
lock.unlock();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -437,7 +442,11 @@ bool wiResourceManager::Register(const wiHashString& name, void* resource, Data_
|
||||
lock.lock();
|
||||
if (resources.find(name) == resources.end())
|
||||
{
|
||||
resources.insert(make_pair(name, new Resource(resource, newType)));
|
||||
Resource res;
|
||||
res.data = resource;
|
||||
res.type = newType;
|
||||
res.refCount = 1;
|
||||
resources.insert(make_pair(name, res));
|
||||
lock.unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -23,20 +23,16 @@ public:
|
||||
HULLSHADER,
|
||||
DOMAINSHADER,
|
||||
COMPUTESHADER,
|
||||
EMPTY,
|
||||
};
|
||||
|
||||
struct Resource
|
||||
{
|
||||
void* data;
|
||||
Data_Type type;
|
||||
long refCount;
|
||||
|
||||
Resource(void* newData, Data_Type newType) :data(newData), type(newType)
|
||||
{
|
||||
refCount = 1;
|
||||
};
|
||||
const void* data = nullptr;
|
||||
Data_Type type = EMPTY;
|
||||
long refCount = 0;
|
||||
};
|
||||
std::unordered_map<wiHashString, Resource*> resources;
|
||||
std::unordered_map<wiHashString, Resource> resources;
|
||||
|
||||
|
||||
public:
|
||||
@@ -44,9 +40,9 @@ public:
|
||||
static wiResourceManager& GetGlobal();
|
||||
static wiResourceManager& GetShaderManager();
|
||||
|
||||
const Resource* get(const wiHashString& name, bool IncRefCount = false);
|
||||
Resource get(const wiHashString& name, bool IncRefCount = false);
|
||||
//specify datatype for shaders
|
||||
void* add(const wiHashString& name, Data_Type newType = Data_Type::DYNAMIC);
|
||||
const void* add(const wiHashString& name, Data_Type newType = Data_Type::DYNAMIC);
|
||||
bool del(const wiHashString& name, bool forceDelete = false);
|
||||
bool Register(const wiHashString& name, void* resource, Data_Type newType);
|
||||
bool Clear();
|
||||
|
||||
@@ -44,18 +44,18 @@ int wiResourceManager_BindLua::Get(lua_State *L)
|
||||
if (argc > 0)
|
||||
{
|
||||
string name = wiLua::SGetString(L, 1);
|
||||
const wiResourceManager::Resource* data = resources->get(name);
|
||||
if (data != nullptr)
|
||||
wiResourceManager::Resource data = resources->get(name);
|
||||
if (data.data != nullptr)
|
||||
{
|
||||
switch (data->type)
|
||||
switch (data.type)
|
||||
{
|
||||
case wiResourceManager::Data_Type::IMAGE_2D:
|
||||
Luna<Texture_BindLua>::push(L, new Texture_BindLua((Texture2D*)data->data));
|
||||
Luna<Texture_BindLua>::push(L, new Texture_BindLua((Texture2D*)data.data));
|
||||
return 1;
|
||||
break;
|
||||
case wiResourceManager::Data_Type::MUSIC:
|
||||
case wiResourceManager::Data_Type::SOUND:
|
||||
Luna<wiSound_BindLua>::push(L, new wiSound_BindLua((wiSound*)data->data));
|
||||
Luna<wiSound_BindLua>::push(L, new wiSound_BindLua((wiSound*)data.data));
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
@@ -95,7 +95,7 @@ int wiResourceManager_BindLua::Add(lua_State *L)
|
||||
else if (!typeStr.compare("MUSIC"))
|
||||
type = wiResourceManager::Data_Type::MUSIC;
|
||||
}
|
||||
void* data = resources->add(name, type);
|
||||
const void* data = resources->add(name, type);
|
||||
wiLua::SSetString(L, (data != nullptr ? "ok" : "not found"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ void Bind()
|
||||
Luna<TransformComponent_BindLua>::Register(L);
|
||||
Luna<CameraComponent_BindLua>::Register(L);
|
||||
Luna<AnimationComponent_BindLua>::Register(L);
|
||||
Luna<MaterialComponent_BindLua>::Register(L);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +58,7 @@ Luna<Scene_BindLua>::FunctionType Scene_BindLua::methods[] = {
|
||||
lunamethod(Scene_BindLua, Component_GetTransform),
|
||||
lunamethod(Scene_BindLua, Component_GetCamera),
|
||||
lunamethod(Scene_BindLua, Component_GetAnimation),
|
||||
lunamethod(Scene_BindLua, Component_GetMaterial),
|
||||
lunamethod(Scene_BindLua, Component_Attach),
|
||||
lunamethod(Scene_BindLua, Component_Detach),
|
||||
lunamethod(Scene_BindLua, Component_DetachChildren),
|
||||
@@ -265,6 +267,23 @@ int Scene_BindLua::Component_GetAnimation(lua_State* L)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int Scene_BindLua::Component_GetMaterial(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
Entity entity = (Entity)wiLua::SGetInt(L, 1);
|
||||
|
||||
MaterialComponent* component = scene->materials.GetComponent(entity);
|
||||
Luna<MaterialComponent_BindLua>::push(L, new MaterialComponent_BindLua(component));
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "Scene::Component_GetAnimation(Entity entity) not enough arguments!");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Scene_BindLua::Component_Attach(lua_State* L)
|
||||
{
|
||||
@@ -771,4 +790,86 @@ int AnimationComponent_BindLua::Stop(lua_State* L)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const char MaterialComponent_BindLua::className[] = "MaterialComponent";
|
||||
|
||||
Luna<MaterialComponent_BindLua>::FunctionType MaterialComponent_BindLua::methods[] = {
|
||||
lunamethod(MaterialComponent_BindLua, SetBaseColor),
|
||||
lunamethod(MaterialComponent_BindLua, SetEmissiveColor),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<MaterialComponent_BindLua>::PropertyType MaterialComponent_BindLua::properties[] = {
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
MaterialComponent_BindLua::MaterialComponent_BindLua(lua_State *L)
|
||||
{
|
||||
owning = true;
|
||||
component = new MaterialComponent;
|
||||
}
|
||||
MaterialComponent_BindLua::~MaterialComponent_BindLua()
|
||||
{
|
||||
if (owning)
|
||||
{
|
||||
delete component;
|
||||
}
|
||||
}
|
||||
|
||||
int MaterialComponent_BindLua::SetBaseColor(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
Vector_BindLua* _color = Luna<Vector_BindLua>::lightcheck(L, 1);
|
||||
if (_color)
|
||||
{
|
||||
XMFLOAT4 color;
|
||||
XMStoreFloat4(&color, _color->vector);
|
||||
component->SetBaseColor(color);
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "SetBaseColor(Vector color) first argument must be of Vector type!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "SetBaseColor(Vector color) not enough arguments!");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
int MaterialComponent_BindLua::SetEmissiveColor(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
Vector_BindLua* _color = Luna<Vector_BindLua>::lightcheck(L, 1);
|
||||
if (_color)
|
||||
{
|
||||
XMFLOAT4 color;
|
||||
XMStoreFloat4(&color, _color->vector);
|
||||
component->SetEmissiveColor(color);
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "SetEmissiveColor(Vector color) first argument must be of Vector type!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "SetEmissiveColor(Vector color) not enough arguments!");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace wiSceneSystem_BindLua
|
||||
int Component_GetTransform(lua_State* L);
|
||||
int Component_GetCamera(lua_State* L);
|
||||
int Component_GetAnimation(lua_State* L);
|
||||
int Component_GetMaterial(lua_State* L);
|
||||
|
||||
int Component_Attach(lua_State* L);
|
||||
int Component_Detach(lua_State* L);
|
||||
@@ -142,5 +143,23 @@ namespace wiSceneSystem_BindLua
|
||||
int Stop(lua_State* L);
|
||||
};
|
||||
|
||||
class MaterialComponent_BindLua
|
||||
{
|
||||
public:
|
||||
bool owning = false;
|
||||
wiSceneSystem::MaterialComponent* component = nullptr;
|
||||
|
||||
static const char className[];
|
||||
static Luna<MaterialComponent_BindLua>::FunctionType methods[];
|
||||
static Luna<MaterialComponent_BindLua>::PropertyType properties[];
|
||||
|
||||
MaterialComponent_BindLua(wiSceneSystem::MaterialComponent* component) :component(component) {}
|
||||
MaterialComponent_BindLua(lua_State *L);
|
||||
~MaterialComponent_BindLua();
|
||||
|
||||
int SetBaseColor(lua_State* L);
|
||||
int SetEmissiveColor(lua_State* L);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wiVersion
|
||||
// minor features, major updates
|
||||
const int minor = 24;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 47;
|
||||
const int revision = 48;
|
||||
|
||||
|
||||
long GetVersion()
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,20 @@
|
||||
-- This script will draw some debug primitives in the world such as line, point, box
|
||||
|
||||
backlog_post("---> START SCRIPT: debug_draw.lua")
|
||||
|
||||
runProcess(function()
|
||||
while true do
|
||||
DrawLine(Vector(-10,4,0), Vector(10,1,1), Vector(1,0,1,1))
|
||||
DrawPoint(Vector(0,4,0), 3, Vector(1,1,0,1))
|
||||
|
||||
local S = matrix.Scale(Vector(1,2,3))
|
||||
local R = matrix.Rotation(Vector(0.2, 0.6))
|
||||
local T = matrix.Translation(Vector(0,2,3))
|
||||
local M = S:Multiply(R):Multiply(T)
|
||||
DrawBox(M, Vector(0,1,1,1))
|
||||
|
||||
render()
|
||||
end
|
||||
end)
|
||||
|
||||
backlog_post("---> END SCRIPT: debug_draw.lua")
|
||||
@@ -0,0 +1,30 @@
|
||||
-- This script will load a teapot model and demonstrate picking it with a ray
|
||||
|
||||
backlog_post("---> START SCRIPT: pick.lua")
|
||||
|
||||
scene = GetScene()
|
||||
scene.Clear()
|
||||
model_entity = LoadModel("../models/teapot.wiscene")
|
||||
|
||||
runProcess(function()
|
||||
local t = 0
|
||||
while true do
|
||||
t = t + 0.05
|
||||
|
||||
-- Create a Ray by specifying origin and direction (and also animate the ray origin along sine wave):
|
||||
local ray = Ray(Vector(math.sin(t) * 4,1,-10), Vector(0,0,1))
|
||||
local entity, position, normal, distance = Pick(ray)
|
||||
|
||||
if(entity ~= INVALID_ENTITY) then
|
||||
-- Draw intersection point as purple X
|
||||
DrawPoint(position, 1, Vector(1,0,1,1))
|
||||
end
|
||||
|
||||
-- Draw ray as yellow line:
|
||||
DrawLine(ray.GetOrigin(), ray.GetOrigin():Add(ray.GetDirection():Multiply(1000)), Vector(1,1,0,1))
|
||||
|
||||
render()
|
||||
end
|
||||
end)
|
||||
|
||||
backlog_post("---> END SCRIPT: pick.lua")
|
||||
@@ -0,0 +1,23 @@
|
||||
-- This script will load a teapot model and animate its base color between red and green
|
||||
|
||||
backlog_post("---> START SCRIPT: set_material_color.lua")
|
||||
|
||||
scene = GetScene()
|
||||
scene.Clear()
|
||||
LoadModel("../models/teapot.wiscene")
|
||||
material_entity = scene.Entity_FindByName("teapot_material") -- query the teapot's material by name
|
||||
material_component = scene.Component_GetMaterial(material_entity)
|
||||
|
||||
runProcess(function()
|
||||
local t = 0
|
||||
while true do
|
||||
t = t + 0.1
|
||||
local red = Vector(1,0,0,1)
|
||||
local green = Vector(0,1,0,1)
|
||||
local color = vector.Lerp(red, green, math.sin(t) * 0.5 + 0.5)
|
||||
material_component.SetBaseColor(color)
|
||||
update()
|
||||
end
|
||||
end)
|
||||
|
||||
backlog_post("---> END SCRIPT: set_material_color.lua")
|
||||
@@ -0,0 +1,23 @@
|
||||
-- This script will load a teapot model and animate its emissive color and intensity
|
||||
|
||||
backlog_post("---> START SCRIPT: set_material_color.lua")
|
||||
|
||||
scene = GetScene()
|
||||
scene.Clear()
|
||||
LoadModel("../models/teapot.wiscene")
|
||||
material_entity = scene.Entity_FindByName("teapot_material") -- query the teapot's material by name
|
||||
material_component = scene.Component_GetMaterial(material_entity)
|
||||
|
||||
runProcess(function()
|
||||
local t = 0
|
||||
while true do
|
||||
t = t + 0.05
|
||||
local startcolor = Vector(1,0,1,0) -- pink, but zero intesity emissive
|
||||
local endcolor = Vector(1,0,1,2) -- 2x intensity pink emissive
|
||||
local color = vector.Lerp(startcolor, endcolor, math.sin(t) * 0.5 + 0.5)
|
||||
material_component.SetEmissiveColor(color)
|
||||
update()
|
||||
end
|
||||
end)
|
||||
|
||||
backlog_post("---> END SCRIPT: set_material_color.lua")
|
||||
Reference in New Issue
Block a user