(basic) shaders compiling

This commit is contained in:
Mischa Spiegelmock
2018-06-02 16:52:15 +02:00
parent c30c6f680f
commit 3c1306e82f
2 changed files with 16 additions and 5 deletions

View File

@ -47,9 +47,10 @@ std::string HLSLShaderTemplate = ""
//" #define tex3d tex3D\n"
//
//" #define sampler sampler2D\n"
//" #define uv_orig uv\n"
// get the color of a pixel rendered by the preset
" uniform sampler2D sampler_main;\n"
" uniform sampler2D sampler_fw_main;\n"
" uniform sampler2D sampler_pw_main;\n"
" uniform sampler2D sampler_fc_main;\n"
@ -107,6 +108,8 @@ std::string HLSLShaderTemplate = ""
//" #define getang atan2(((uv.y-0.5)*2),((uv.x-0.5)*2))\n"
//" float rad = sqrt((uv.x-0.5)*2*(uv.x-0.5)*2+(uv.y-0.5)*2*(uv.y-0.5)*2)*.7071067;\n"
//" float getang = atan2(((uv.y-0.5)*2),((uv.x-0.5)*2));\n"
" float3 getrad(float2 uv) { return sqrt((uv.x-0.5)*2*(uv.x-0.5)*2+(uv.y-0.5)*2*(uv.y-0.5)*2)*.7071067; };\n"
" float3 getang(float2 uv) { return atan2(((uv.y-0.5)*2),((uv.x-0.5)*2)); };\n"
//" #define GetMain(uv) (tex2D(sampler_main,uv).xyz)\n"
//" #define GetPixel(uv) (tex2D(sampler_main,uv).xyz)\n"
@ -135,9 +138,9 @@ std::string HLSLShaderTemplate = ""
" a.z > b.z ? a.z : b.z );\n"
" }\n"
" struct outtype {float4 color : COLOR;};\n"
" outtype OUT;\n"
" float3 ret;\n\n";
" struct outtype {float4 color : COLOR;};\n";
//" outtype OUT;\n";
//" static float3 ret;\n\n";
std::unique_ptr<std::string> HLSLTranslator::parse(GLenum shaderType, const char *fileName, std::string &source) {

View File

@ -148,7 +148,15 @@ bool ShaderEngine::LoadHLSLProgram(GLenum shaderType, Shader &pmShader, std::str
if (found != std::string::npos)
{
//std::cout << "first '{' found at: " << int(found) << std::endl;
// program.replace(int(found), 1, "{\nfloat rad=getrad;\nfloat ang=getang;\n");
// program.replace(int(found), 1, "{\nfloat rad=getrad;\nfloat ang=getang;\n");
const char *progMain = \
"{\n"
"float2 uv_orig = uv;\n"
"float rad=getrad(uv);\n"
"float ang=getang(uv);\n"
"float3 ret;\n"
"outtype OUT;\n";
program.replace(int(found), 1, progMain);
}
else
return false;