Skip to content

Commit 31a2c5b

Browse files
committed
Update
1 parent d157f9d commit 31a2c5b

File tree

7 files changed

+118
-48
lines changed

7 files changed

+118
-48
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Franx
3+
Copyright (c) 2020 Franx
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
# PluginShadertoy
2-
SHADERed plugin that simplifies the process of loading Shadertoy projects.
2+
SHADERed plugin that simplifies the process of porting your Shadertoy projects.
33

44
![Screenshot](./screen.gif)
55

66
## How to build
77
Clone the project:
88
```bash
99
git clone https://github.com/dfranx/PluginShadertoy.git
10-
git submodule init
11-
git submodule update
10+
git submodule update --init
1211
```
1312

1413
### Linux
15-
1. Install OpenSSL (libcrypro & libssl).
14+
1. Install OpenSSL (libcrypto & libssl).
1615

1716
2. Build:
1817
```bash
@@ -27,11 +26,10 @@ make
2726
4. Open the .sln and build the project!
2827

2928
## How to use
30-
This plugin requires SHADERed v1.3 minimum.
29+
This plugin requires at least SHADERed v1.3.5.
3130

32-
Copy the .dll/.so file to plugins/Shadertoy in your SHADERed installation directory
31+
Copy the .dll/.so file to `plugins/Shadertoy` folder in your SHADERed's installation directory
3332

3433
## TODO
3534
- cubemaps
3635
- audio shaders
37-
- texture properties

Shadertoy.h

+36-16
Original file line numberDiff line numberDiff line change
@@ -73,37 +73,55 @@ namespace st
7373
virtual void Object_ShowContext(const char* type, void* data) { }
7474

7575
// pipeline item stuff
76-
virtual bool PipelineItem_HasProperties(const char* type) { return 0; }
76+
virtual bool PipelineItem_HasProperties(const char* type, void* data) { return 0; }
7777
virtual void PipelineItem_ShowProperties(const char* type, void* data) { }
78-
virtual bool PipelineItem_IsPickable(const char* type) { return 0; }
79-
virtual bool PipelineItem_HasShaders(const char* type) { return 0; }
80-
virtual void PipelineItem_OpenInEditor(void* ui, const char* type, void* data) { }
81-
virtual bool PipelineItem_CanHaveChild(const char* type, ed::plugin::PipelineItemType itemType) { return 0; }
82-
virtual int PipelineItem_GetInputLayoutSize(const char* itemName) { return 0; }
83-
virtual void PipelineItem_GetInputLayoutItem(const char* itemName, int index, ed::plugin::InputLayoutItem& out) { }
78+
virtual bool PipelineItem_IsPickable(const char* type, void* data) { return 0; }
79+
virtual bool PipelineItem_HasShaders(const char* type, void* data) { return 0; }
80+
virtual void PipelineItem_OpenInEditor(const char* type, void* data) { }
81+
virtual bool PipelineItem_CanHaveChild(const char* type, void* data, ed::plugin::PipelineItemType itemType) { return 0; }
82+
virtual int PipelineItem_GetInputLayoutSize(const char* type, void* data) { return 0; }
83+
virtual void PipelineItem_GetInputLayoutItem(const char* type, void* data, int index, ed::plugin::InputLayoutItem& out) { }
8484
virtual void PipelineItem_Remove(const char* itemName, const char* type, void* data) { }
8585
virtual void PipelineItem_Rename(const char* oldName, const char* newName) { }
8686
virtual void PipelineItem_AddChild(const char* owner, const char* name, ed::plugin::PipelineItemType type, void* data) { }
87-
virtual bool PipelineItem_CanHaveChildren(const char* type) { return 0; }
87+
virtual bool PipelineItem_CanHaveChildren(const char* type, void* data) { return 0; }
8888
virtual void* PipelineItem_CopyData(const char* type, void* data) { return 0; }
8989
virtual void PipelineItem_Execute(void* Owner, ed::plugin::PipelineItemType OwnerType, const char* type, void* data) { }
9090
virtual void PipelineItem_Execute(const char* type, void* data, void* children, int count) { }
91-
virtual void PipelineItem_GetWorldMatrix(void* data, float(&pMat)[16]) { }
91+
virtual void PipelineItem_GetWorldMatrix(const char* type, void* data, float(&pMat)[16]) { }
9292
virtual bool PipelineItem_Intersect(const char* type, void* data, const float* rayOrigin, const float* rayDir, float& hitDist) { return 0; }
93-
virtual void PipelineItem_GetBoundingBox(void* data, float(&minPos)[3], float(&maxPos)[3]) { }
94-
virtual bool PipelineItem_HasContext(const char* type) { return 0; }
93+
virtual void PipelineItem_GetBoundingBox(const char* type, void* data, float(&minPos)[3], float(&maxPos)[3]) { }
94+
virtual bool PipelineItem_HasContext(const char* type, void* data) { return 0; }
9595
virtual void PipelineItem_ShowContext(const char* type, void* data) { }
9696
virtual const char* PipelineItem_Export(const char* type, void* data) { return 0; }
9797
virtual void* PipelineItem_Import(const char* ownerName, const char* name, const char* type, const char* argsString) { return 0; }
9898
virtual void PipelineItem_MoveDown(void* ownerData, const char* ownerType, const char* itemName) { }
9999
virtual void PipelineItem_MoveUp(void* ownerData, const char* ownerType, const char* itemName) { }
100-
virtual void PipelineItem_ApplyGizmoTransform(void* data, float* transl, float* scale, float* rota) { }
101-
virtual void PipelineItem_GetTransform(void* data, float* transl, float* scale, float* rota) { }
100+
virtual void PipelineItem_ApplyGizmoTransform(const char* type, void* data, float* transl, float* scale, float* rota) { }
101+
virtual void PipelineItem_GetTransform(const char* type, void* data, float* transl, float* scale, float* rota) { }
102102
virtual void PipelineItem_DebugVertexExecute(void* Owner, ed::plugin::PipelineItemType OwnerType, const char* type, void* data, unsigned int colorVarLoc) { }
103+
virtual int PipelineItem_DebugVertexExecute(const char* type, void* data, const char* childName, float rx, float ry, int vertexGroup) { return 0; }
103104
virtual void PipelineItem_DebugInstanceExecute(void* Owner, ed::plugin::PipelineItemType OwnerType, const char* type, void* data, unsigned int colorVarLoc) { }
104-
virtual unsigned int PipelineItem_GetVBO(void* data) { return 0; }
105-
virtual unsigned int PipelineItem_GetVBOStride(void* data) { return 0; }
106-
virtual bool PipelineItem_CanChangeVariables(void* data) { return 0; }
105+
virtual int PipelineItem_DebugInstanceExecute(const char* type, void* data, const char* childName, float rx, float ry, int vertexGroup) { return 0; }
106+
virtual unsigned int PipelineItem_GetVBO(const char* type, void* data) { return 0; }
107+
virtual unsigned int PipelineItem_GetVBOStride(const char* type, void* data) { return 0; }
108+
virtual bool PipelineItem_CanChangeVariables(const char* type, void* data) { return 0; }
109+
virtual bool PipelineItem_IsDebuggable(const char* type, void* data) { return 0; }
110+
virtual bool PipelineItem_IsStageDebuggable(const char* type, void* data, ed::plugin::ShaderStage stage) { return 0; }
111+
virtual void PipelineItem_DebugExecute(const char* type, void* data, void* children, int count, int* debugID) { }
112+
virtual unsigned int PipelineItem_GetTopology(const char* type, void* data) { return 0; }
113+
virtual unsigned int PipelineItem_GetVariableCount(const char* type, void* data) { return 0; }
114+
virtual const char* PipelineItem_GetVariableName(const char* type, void* data, unsigned int variable) { return 0; }
115+
virtual ed::plugin::VariableType PipelineItem_GetVariableType(const char* type, void* data, unsigned int variable) { return ed::plugin::VariableType::Float1; }
116+
virtual float PipelineItem_GetVariableValueFloat(const char* type, void* data, unsigned int variable, int col, int row) { return 0; }
117+
virtual int PipelineItem_GetVariableValueInteger(const char* type, void* data, unsigned int variable, int col) { return 0; }
118+
virtual bool PipelineItem_GetVariableValueBoolean(const char* type, void* data, unsigned int variable, int col) { return 0; }
119+
virtual unsigned int PipelineItem_GetSPIRVSize(const char* type, void* data, ed::plugin::ShaderStage stage) { return 0; }
120+
virtual unsigned int* PipelineItem_GetSPIRV(const char* type, void* data, ed::plugin::ShaderStage stage) { return 0; }
121+
virtual void PipelineItem_DebugPrepareVariables(const char* type, void* data, const char* name) { }
122+
virtual bool PipelineItem_DebugUsesCustomTextures(const char* type, void* data) { return 0; }
123+
virtual unsigned int PipelineItem_DebugGetTexture(const char* type, void* data, int loc, const char* variableName) { return 0; }
124+
virtual void PipelineItem_DebugGetTextureSize(const char* type, void* data, int loc, const char* variableName, int& x, int& y, int& z) { }
107125

108126
// options
109127
virtual bool Options_HasSection() { return 0; }
@@ -119,6 +137,8 @@ namespace st
119137
virtual const unsigned int* CustomLanguage_CompileToSPIRV(int langID, const char* src, size_t src_len, ed::plugin::ShaderStage stage, const char* entry, ed::plugin::ShaderMacro* macros, size_t macroCount, size_t* spv_length, bool* compiled) { return 0; }
120138
virtual const char* CustomLanguage_ProcessGeneratedGLSL(int langID, const char* src) { return 0; }
121139
virtual bool CustomLanguage_SupportsAutoUniforms(int langID) { return 0; }
140+
virtual bool CustomLanguage_IsDebuggable(int langID) { return 0; }
141+
virtual const char* CustomLanguage_GetDefaultExtension(int langID) { return 0; }
122142

123143
// language text editor
124144
virtual bool ShaderEditor_Supports(int langID) { return 0; }

dllmain.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extern "C" {
2222
delete ptr;
2323
}
2424
FEXPORT int GetPluginAPIVersion() {
25-
return 1;
25+
return 3;
2626
}
2727
FEXPORT int GetPluginVersion() {
2828
return 1;

inc/PluginAPI/Plugin.h

+67-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
2-
#include "PluginData.h"
2+
#include <PluginAPI/PluginData.h>
33
#include <stddef.h>
44

55
namespace ed {
@@ -64,6 +64,7 @@ namespace ed {
6464
typedef void (*GetMousePositionFn)(float& x, float& y);
6565
typedef int (*GetFrameIndexFn)();
6666
typedef float (*GetTimeFn)();
67+
typedef void (*SetTimeFn)(float time);
6768
typedef void (*SetGeometryTransformFn)(void* item, float scale[3], float rota[3], float pos[3]);
6869
typedef void (*SetMousePositionFn)(float x, float y);
6970
typedef void (*SetKeysWASDFn)(bool w, bool a, bool s, bool d);
@@ -81,6 +82,10 @@ namespace ed {
8182
typedef unsigned int (*GetFlippedTextureFn)(void* objects, const char* name);
8283
typedef void (*GetTextureSizeFn)(void* objects, const char* name, int& w, int& h);
8384

85+
typedef bool (*IsRenderTextureFn)(void* objects, const char* name);
86+
typedef void (*GetRenderTextureSizeFn)(void* objects, const char* name, int& w, int& h);
87+
typedef unsigned int (*GetDepthTextureFn)(void* objects, const char* name);
88+
8489
typedef void (*BindDefaultStateFn)();
8590
typedef void (*OpenInCodeEditorFn)(void* UI, void* item, const char* filename, int id);
8691

@@ -114,6 +119,17 @@ namespace ed {
114119
typedef bool (*IsInPerformanceModeFn)(void* UI);
115120

116121
typedef void (*PushNotificationFn)(void* UI, void* plugin, int id, const char* text, const char* buttonText);
122+
123+
typedef void (*DebuggerJumpFn)(void* Debugger, void* TextEditor, int line);
124+
typedef void (*DebuggerContinueFn)(void* Debugger, void* TextEditor);
125+
typedef void (*DebuggerStepFn)(void* Debugger, void* TextEditor);
126+
typedef void (*DebuggerStepIntoFn)(void* Debugger, void* TextEditor);
127+
typedef void (*DebuggerStepOutFn)(void* Debugger, void* TextEditor);
128+
typedef bool (*DebuggerCheckBreakpointFn)(void* Debugger, void* TextEditor, int line);
129+
typedef bool (*DebuggerIsDebuggingFn)(void* Debugger, void* TextEditor);
130+
typedef int (*DebuggerGetCurrentLineFn)(void* Debugger);
131+
132+
typedef float (*ScaleSizeFn)(float size);
117133
}
118134

119135
// CreatePlugin(), DestroyPlugin(ptr), GetPluginAPIVersion(), GetPluginVersion(), GetPluginName()
@@ -184,37 +200,55 @@ namespace ed {
184200
virtual void Object_ShowContext(const char* type, void* data) = 0;
185201

186202
// pipeline item stuff
187-
virtual bool PipelineItem_HasProperties(const char* type) = 0;
203+
virtual bool PipelineItem_HasProperties(const char* type, void* data) = 0;
188204
virtual void PipelineItem_ShowProperties(const char* type, void* data) = 0;
189-
virtual bool PipelineItem_IsPickable(const char* type) = 0;
190-
virtual bool PipelineItem_HasShaders(const char* type) = 0; // so that they can be opened in the shader editor
191-
virtual void PipelineItem_OpenInEditor(void* ui, const char* type, void* data) = 0;
192-
virtual bool PipelineItem_CanHaveChild(const char* type, plugin::PipelineItemType itemType) = 0;
193-
virtual int PipelineItem_GetInputLayoutSize(const char* itemName) = 0; // this must be supported if this item can have geometry as child..
194-
virtual void PipelineItem_GetInputLayoutItem(const char* itemName, int index, plugin::InputLayoutItem& out) = 0;
205+
virtual bool PipelineItem_IsPickable(const char* type, void* data) = 0;
206+
virtual bool PipelineItem_HasShaders(const char* type, void* data) = 0; // so that they can be opened in the shader editor
207+
virtual void PipelineItem_OpenInEditor(const char* type, void* data) = 0;
208+
virtual bool PipelineItem_CanHaveChild(const char* type, void* data, plugin::PipelineItemType itemType) = 0;
209+
virtual int PipelineItem_GetInputLayoutSize(const char* type, void* data) = 0; // this must be supported if this item can have geometry as child..
210+
virtual void PipelineItem_GetInputLayoutItem(const char* type, void* data, int index, plugin::InputLayoutItem& out) = 0;
195211
virtual void PipelineItem_Remove(const char* itemName, const char* type, void* data) = 0;
196212
virtual void PipelineItem_Rename(const char* oldName, const char* newName) = 0;
197213
virtual void PipelineItem_AddChild(const char* owner, const char* name, plugin::PipelineItemType type, void* data) = 0;
198-
virtual bool PipelineItem_CanHaveChildren(const char* type) = 0;
214+
virtual bool PipelineItem_CanHaveChildren(const char* type, void* data) = 0;
199215
virtual void* PipelineItem_CopyData(const char* type, void* data) = 0;
200216
virtual void PipelineItem_Execute(void* Owner, plugin::PipelineItemType OwnerType, const char* type, void* data) = 0;
201217
virtual void PipelineItem_Execute(const char* type, void* data, void* children, int count) = 0;
202-
virtual void PipelineItem_GetWorldMatrix(void* data, float (&pMat)[16]) = 0; //must be implemented if item is pickable
218+
virtual void PipelineItem_GetWorldMatrix(const char* type, void* data, float (&pMat)[16]) = 0; //must be implemented if item is pickable
203219
virtual bool PipelineItem_Intersect(const char* type, void* data, const float* rayOrigin, const float* rayDir, float& hitDist) = 0;
204-
virtual void PipelineItem_GetBoundingBox(void* data, float (&minPos)[3], float (&maxPos)[3]) = 0;
205-
virtual bool PipelineItem_HasContext(const char* type) = 0;
220+
virtual void PipelineItem_GetBoundingBox(const char* type, void* data, float (&minPos)[3], float (&maxPos)[3]) = 0;
221+
virtual bool PipelineItem_HasContext(const char* type, void* data) = 0;
206222
virtual void PipelineItem_ShowContext(const char* type, void* data) = 0;
207223
virtual const char* PipelineItem_Export(const char* type, void* data) = 0;
208224
virtual void* PipelineItem_Import(const char* ownerName, const char* name, const char* type, const char* argsString) = 0;
209225
virtual void PipelineItem_MoveDown(void* ownerData, const char* ownerType, const char* itemName) = 0;
210226
virtual void PipelineItem_MoveUp(void* ownerData, const char* ownerType, const char* itemName) = 0;
211-
virtual void PipelineItem_ApplyGizmoTransform(void* data, float* transl, float* scale, float* rota) = 0;
212-
virtual void PipelineItem_GetTransform(void* data, float* transl, float* scale, float* rota) = 0;
227+
virtual void PipelineItem_ApplyGizmoTransform(const char* type, void* data, float* transl, float* scale, float* rota) = 0;
228+
virtual void PipelineItem_GetTransform(const char* type, void* data, float* transl, float* scale, float* rota) = 0;
213229
virtual void PipelineItem_DebugVertexExecute(void* Owner, plugin::PipelineItemType OwnerType, const char* type, void* data, unsigned int colorVarLoc) = 0;
230+
virtual int PipelineItem_DebugVertexExecute(const char* type, void* data, const char* childName, float rx, float ry, int vertexGroup) = 0;
214231
virtual void PipelineItem_DebugInstanceExecute(void* Owner, plugin::PipelineItemType OwnerType, const char* type, void* data, unsigned int colorVarLoc) = 0;
215-
virtual unsigned int PipelineItem_GetVBO(void* data) = 0;
216-
virtual unsigned int PipelineItem_GetVBOStride(void* data) = 0;
217-
virtual bool PipelineItem_CanChangeVariables(void* data) = 0;
232+
virtual int PipelineItem_DebugInstanceExecute(const char* type, void* data, const char* childName, float rx, float ry, int vertexGroup) = 0;
233+
virtual unsigned int PipelineItem_GetVBO(const char* type, void* data) = 0;
234+
virtual unsigned int PipelineItem_GetVBOStride(const char* type, void* data) = 0;
235+
virtual bool PipelineItem_CanChangeVariables(const char* type, void* data) = 0;
236+
virtual bool PipelineItem_IsDebuggable(const char* type, void* data) = 0;
237+
virtual bool PipelineItem_IsStageDebuggable(const char* type, void* data, ed::plugin::ShaderStage stage) = 0;
238+
virtual void PipelineItem_DebugExecute(const char* type, void* data, void* children, int count, int* debugID) = 0;
239+
virtual unsigned int PipelineItem_GetTopology(const char* type, void* data) = 0;
240+
virtual unsigned int PipelineItem_GetVariableCount(const char* type, void* data) = 0;
241+
virtual const char* PipelineItem_GetVariableName(const char* type, void* data, unsigned int variable) = 0;
242+
virtual ed::plugin::VariableType PipelineItem_GetVariableType(const char* type, void* data, unsigned int variable) = 0;
243+
virtual float PipelineItem_GetVariableValueFloat(const char* type, void* data, unsigned int variable, int col, int row) = 0;
244+
virtual int PipelineItem_GetVariableValueInteger(const char* type, void* data, unsigned int variable, int col) = 0;
245+
virtual bool PipelineItem_GetVariableValueBoolean(const char* type, void* data, unsigned int variable, int col) = 0;
246+
virtual unsigned int PipelineItem_GetSPIRVSize(const char* type, void* data, ed::plugin::ShaderStage stage) = 0;
247+
virtual unsigned int* PipelineItem_GetSPIRV(const char* type, void* data, ed::plugin::ShaderStage stage) = 0;
248+
virtual void PipelineItem_DebugPrepareVariables(const char* type, void* data, const char* name) = 0;
249+
virtual bool PipelineItem_DebugUsesCustomTextures(const char* type, void* data) = 0;
250+
virtual unsigned int PipelineItem_DebugGetTexture(const char* type, void* data, int loc, const char* variableName) = 0;
251+
virtual void PipelineItem_DebugGetTextureSize(const char* type, void* data, int loc, const char* variableName, int& x, int& y, int& z) = 0;
218252

219253
// options
220254
virtual bool Options_HasSection() = 0;
@@ -230,6 +264,8 @@ namespace ed {
230264
virtual const unsigned int* CustomLanguage_CompileToSPIRV(int langID, const char* src, size_t src_len, plugin::ShaderStage stage, const char* entry, plugin::ShaderMacro* macros, size_t macroCount, size_t* spv_length, bool* compiled) = 0;
231265
virtual const char* CustomLanguage_ProcessGeneratedGLSL(int langID, const char* src) = 0;
232266
virtual bool CustomLanguage_SupportsAutoUniforms(int langID) = 0;
267+
virtual bool CustomLanguage_IsDebuggable(int langID) = 0;
268+
virtual const char* CustomLanguage_GetDefaultExtension(int langID) = 0;
233269

234270
// language text editor
235271
virtual bool ShaderEditor_Supports(int langID) = 0;
@@ -290,7 +326,7 @@ namespace ed {
290326
virtual void HandleNotification(int id) = 0;
291327

292328
// host functions
293-
void *Renderer, *Messages, *Project, *UI, *ObjectManager, *PipelineManager, *Plugins;
329+
void *Renderer, *Messages, *Project, *UI, *ObjectManager, *PipelineManager, *Plugins, *Debugger;
294330
pluginfn::AddObjectFn AddObject;
295331
pluginfn::AddCustomPipelineItemFn AddCustomPipelineItem;
296332
pluginfn::AddMessageFn AddMessage;
@@ -326,6 +362,7 @@ namespace ed {
326362
pluginfn::GetMousePositionFn GetMousePosition;
327363
pluginfn::GetFrameIndexFn GetFrameIndex;
328364
pluginfn::GetTimeFn GetTime;
365+
pluginfn::SetTimeFn SetTime;
329366
pluginfn::SetGeometryTransformFn SetGeometryTransform;
330367
pluginfn::SetMousePositionFn SetMousePosition;
331368
pluginfn::SetKeysWASDFn SetKeysWASD;
@@ -384,5 +421,17 @@ namespace ed {
384421
pluginfn::TogglePerformanceModeFn TogglePerformanceMode;
385422
pluginfn::IsInPerformanceModeFn IsInPerformanceMode;
386423
pluginfn::PushNotificationFn PushNotification;
424+
pluginfn::DebuggerJumpFn DebuggerJump;
425+
pluginfn::DebuggerContinueFn DebuggerContinue;
426+
pluginfn::DebuggerStepFn DebuggerStep;
427+
pluginfn::DebuggerStepIntoFn DebuggerStepInto;
428+
pluginfn::DebuggerStepOutFn DebuggerStepOut;
429+
pluginfn::DebuggerCheckBreakpointFn DebuggerCheckBreakpoint;
430+
pluginfn::DebuggerIsDebuggingFn DebuggerIsDebugging;
431+
pluginfn::DebuggerGetCurrentLineFn DebuggerGetCurrentLine;
432+
pluginfn::IsRenderTextureFn IsRenderTexture;
433+
pluginfn::GetRenderTextureSizeFn GetRenderTextureSize;
434+
pluginfn::GetDepthTextureFn GetDepthTexture;
435+
pluginfn::ScaleSizeFn ScaleSize;
387436
};
388437
}

0 commit comments

Comments
 (0)