Commit d8e1eb46 authored by pcy's avatar pcy
Browse files

attrib, uniform querying

parent fce0e19d
...@@ -51,7 +51,7 @@ namespace PoroCYon.FNAGLSL { ...@@ -51,7 +51,7 @@ namespace PoroCYon.FNAGLSL {
EffectTechnique fakeTech; EffectTechnique fakeTech;
readonly static List<EffectTechnique> emptyEffTechList = new List<EffectTechnique>(); //readonly static List<EffectTechnique> emptyEffTechList = new List<EffectTechnique>();
public unsafe GLSLEffect(GraphicsDevice gd, public unsafe GLSLEffect(GraphicsDevice gd,
IDictionary<GLSLPurpose, string> shaders) IDictionary<GLSLPurpose, string> shaders)
: base(/*UGLY hack*/new BasicEffect(gd)) { : base(/*UGLY hack*/new BasicEffect(gd)) {
...@@ -103,12 +103,9 @@ namespace PoroCYon.FNAGLSL { ...@@ -103,12 +103,9 @@ namespace PoroCYon.FNAGLSL {
if (GL.GetError() != 0 || GL.GetShaderiv(sh, GL.COMPILE_STATUS) == 0) { if (GL.GetError() != 0 || GL.GetShaderiv(sh, GL.COMPILE_STATUS) == 0) {
int len = GL.GetShaderiv(sh, GL.INFO_LOG_LENGTH); int len = GL.GetShaderiv(sh, GL.INFO_LOG_LENGTH);
var msg = new sbyte[len]; var msg = GL.GetShaderInfoLog(sh, len);
fixed (sbyte* buf = msg) {
GL.GetShaderInfoLog(sh, len, null, buf);
throw new GLSLCompileException("Failed to compile " throw new GLSLCompileException("Failed to compile "
+ kvp.Key + ": " + new String(buf, 0, len-1)); + kvp.Key + ": " + msg);
}
} }
GL.AttachShader(prgm, sh); GL.AttachShader(prgm, sh);
...@@ -120,14 +117,15 @@ namespace PoroCYon.FNAGLSL { ...@@ -120,14 +117,15 @@ namespace PoroCYon.FNAGLSL {
GL.LinkProgram(prgm); GL.LinkProgram(prgm);
if (GL.GetError() != 0 || GL.GetProgramiv(prgm, GL.LINK_STATUS) == 0) { if (GL.GetError() != 0 || GL.GetProgramiv(prgm, GL.LINK_STATUS) == 0) {
int len = GL.GetProgramiv(prgm, GL.INFO_LOG_LENGTH); int len = GL.GetProgramiv(prgm, GL.INFO_LOG_LENGTH);
var msg = new sbyte[len]; var msg = GL.GetProgramInfoLog(prgm, len);
fixed (sbyte* buf = msg) { throw new GLSLLinkException("Failed to link shader: " + msg);
GL.GetProgramInfoLog(prgm, len, null, buf);
throw new GLSLLinkException("Failed to link shader: "
+ new String(buf, 0, len-1));
}
} }
glshdrs = shdrs;
glprgm = prgm ;
ParseAttribUnif();
ok = true; ok = true;
} }
finally { finally {
...@@ -140,6 +138,46 @@ namespace PoroCYon.FNAGLSL { ...@@ -140,6 +138,46 @@ namespace PoroCYon.FNAGLSL {
} }
} }
void ParseAttribUnif() {
// TODO: build EffectParameter stuff
int attrs = GL.GetProgramiv(glprgm, GL.ACTIVE_ATTRIBUTES);
GL.Throw();
Console.WriteLine("#attrs = " + attrs);
for (int i = 0; i < attrs; ++i) {
int size; GLSLType type; string name;
GL.GetActiveAttrib(glprgm, unchecked((uint)i), out size,
out type, out name);
GL.Throw();
int loc = GL.GetAttribLocation(glprgm, name);
GL.Throw();
Console.WriteLine("attrs["+i+"] = {size=" + size + ", type="
+ type + ", name=" + name + ", loc="+loc+"}");
}
int unifs = GL.GetProgramiv(glprgm, GL.ACTIVE_UNIFORMS);
GL.Throw();
Console.WriteLine("#unifs = " + unifs);
for (int i = 0; i < unifs; ++i) {
int size; GLSLType type; string name;
GL.GetActiveUniform(glprgm, unchecked((uint)i), out size,
out type, out name);
GL.Throw();
int loc = GL.GetUniformLocation(glprgm, name);
GL.Throw();
Console.WriteLine("unifs["+i+"] = {size=" + size + ", type="
+ type + ", name=" + name + ", loc="+loc+"}");
}
/* #attrs = 1
* attrs[0] = {size=1, type=FLOAT_VEC3, name=in_pos, loc=0}
* #unifs = 2
* unifs[0] = {size=1, type=FLOAT, name=fGlobalTime, loc=0}
* unifs[1] = {size=1, type=FLOAT_VEC2, name=v2Resolution, loc=1}
*/
}
// TODO: find out a better (i.e. more API-conform) way to do this! // TODO: find out a better (i.e. more API-conform) way to do this!
///<summary> ///<summary>
///USAGE: using (var eff &eq; glslEffect.Bind()) { ... gd.DrawPrimitives(...); ... } ///USAGE: using (var eff &eq; glslEffect.Bind()) { ... gd.DrawPrimitives(...); ... }
......
...@@ -49,5 +49,69 @@ namespace PoroCYon.FNAGLSL { ...@@ -49,5 +49,69 @@ namespace PoroCYon.FNAGLSL {
FragmentShader = 0x8B30, FragmentShader = 0x8B30,
//ComputeShader = 0x91B9 //ComputeShader = 0x91B9
} }
public enum GLSLType : uint/*GLenum*/ {
FLOAT = 0x1406,
FLOAT_VEC2 = 0x8B50,
FLOAT_VEC3 = 0x8B51,
FLOAT_VEC4 = 0x8B52,
INT = 0x1404,
INT_VEC2 = 0x8B53,
INT_VEC3 = 0x8B54,
INT_VEC4 = 0x8B55,
UNSIGNED_INT = 0x1405,
UNSIGNED_INT_VEC2 = 0x8DC6,
UNSIGNED_INT_VEC3 = 0x8DC7,
UNSIGNED_INT_VEC4 = 0x8DC8,
BOOL = 0x8B56,
BOOL_VEC2 = 0x8B57,
BOOL_VEC3 = 0x8B58,
BOOL_VEC4 = 0x8B59,
FLOAT_MAT2 = 0x8B5A,
FLOAT_MAT3 = 0x8B5B,
FLOAT_MAT4 = 0x8B5C,
FLOAT_MAT2x3 = 0x8B65,
FLOAT_MAT2x4 = 0x8B66,
FLOAT_MAT3x2 = 0x8B67,
FLOAT_MAT3x4 = 0x8B68,
FLOAT_MAT4x2 = 0x8B69,
FLOAT_MAT4x3 = 0x8B6A,
SAMPLER_1D = 0x8B5D,
SAMPLER_2D = 0x8B5E,
SAMPLER_3D = 0x8B5F,
SAMPLER_CUBE = 0x8B60,
SAMPLER_1D_SHADOW = 0x8B61,
SAMPLER_2D_SHADOW = 0x8B62,
SAMPLER_1D_ARRAY = 0x8DC0,
SAMPLER_2D_ARRAY = 0x0DC1,
SAMPLER_1D_ARRAY_SHADOW = 0x8DC3,
SAMPLER_2D_ARRAY_SHADOW = 0x8DC4,
SAMPLER_CUBE_SHADOW = 0x8DC5,
SAMPLER_2D_MULTISAMPLE = 0x9108,
SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910B,
SAMPLER_2D_RECT = 0x8B63,
SAMPLER_2D_RECT_SHADOW = 0x8B64,
SAMPLER_BUFFER = 0x8DC2,
INT_SAMPLER_1D = 0x8DC9,
INT_SAMPLER_2D = 0x8DCA,
INT_SAMPLER_3D = 0x8DCB,
INT_SAMPLER_CUBE = 0x8DCD,
INT_SAMPLER_1D_ARRAY = 0x8DCE,
INT_SAMPLER_2D_ARRAY = 0x8DCF,
INT_SAMPLER_2D_MULTISAMPLE = 0x9109,
INT_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910C,
INT_SAMPLER_BUFFER = 0x8DD0,
INT_SAMPLER_2D_RECT = 0x8DCD,
UNSIGNED_INT_SAMPLER_1D = 0x8DD1,
UNSIGNED_INT_SAMPLER_2D = 0x8DD2,
UNSIGNED_INT_SAMPLER_3D = 0x8DD3,
UNSIGNED_INT_SAMPLER_CUBE = 0x8DD4,
UNSIGNED_INT_SAMPLER_1D_ARRAY = 0x8DD6,
UNSIGNED_INT_SAMPLER_2D_ARRAY = 0x8DD7,
UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE = 0x910A,
UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY = 0x910D,
UNSIGNED_INT_SAMPLER_BUFFER = 0x8DD8,
UNSIGNED_INT_SAMPLER_2D_RECT = 0x8DD5
}
} }
using System;
using System.Collections.Generic;
using System.Linq;
namespace PoroCYon.FNAGLSL {
public static unsafe partial class GL {
public const uint
COMPILE_STATUS = 0x8B81,
INFO_LOG_LENGTH = 0x8B84,
LINK_STATUS = 0x8B82,
CURRENT_PROGRAM = 0x8B8D,
ACTIVE_ATTRIBUTES = 0x8B89,
ACTIVE_UNIFORMS = 0x8B86,
INVALID_INDEX = 0xFFFFFFFFu,
UNIFORM_TYPE = 0x8A37,
UNIFORM_SIZE = 0x8A38,
UNIFORM_NAME_LENGTH = 0x8A39,
UNIFORM_BLOCK_INDEX = 0x8A3A,
UNIFORM_OFFSET = 0x8A3B,
UNIFORM_ARRAY_STRIDE = 0x8A3C,
UNIFORM_MATRIX_STRIDE = 0x8A3D,
UNIFORM_IS_ROW_MAJOR = 0x8A3E,
UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX = 0x92DA,
UNIFORM_BLOCK_BINDING = 0x8A3F,
UNIFORM_BLOCK_DATA_SIZE = 0x8A40,
UNIFORM_BLOCK_NAME_LENGTH = 0x8A41,
UNIFORM_BLOCK_ACTIVE_UNIFORMS = 0x8A42,
UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES = 0x8A43,
UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER = 0x8A44,
UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER = 0x8A45,
UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER = 0x8A46,
UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER = 0x84F0,
UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER = 0x84F1;
}
}
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using GLenum = System.UInt32; using GLenum = System.UInt32;
using GLboolean = System.Byte ; using GLboolean = System.Byte ;
...@@ -21,12 +22,6 @@ using GLchar = System.SByte ; ...@@ -21,12 +22,6 @@ using GLchar = System.SByte ;
namespace PoroCYon.FNAGLSL { namespace PoroCYon.FNAGLSL {
public static unsafe partial class GL { public static unsafe partial class GL {
public const GLenum
COMPILE_STATUS = 0x8B81,
INFO_LOG_LENGTH = 0x8B84,
LINK_STATUS = 0x8B82,
CURRENT_PROGRAM = 0x8B8D;
static void InitProcs() { static void InitProcs() {
_GetError = GetProcAddress<GetError_T>("GetError"); _GetError = GetProcAddress<GetError_T>("GetError");
_CreateProgram = GetProcAddress<CreateProgram_T>("CreateProgram"); _CreateProgram = GetProcAddress<CreateProgram_T>("CreateProgram");
...@@ -43,6 +38,13 @@ namespace PoroCYon.FNAGLSL { ...@@ -43,6 +38,13 @@ namespace PoroCYon.FNAGLSL {
_DeleteProgram = GetProcAddress<DeleteProgram_T>("DeleteProgram"); _DeleteProgram = GetProcAddress<DeleteProgram_T>("DeleteProgram");
_UseProgram = GetProcAddress<UseProgram_T>("UseProgram"); _UseProgram = GetProcAddress<UseProgram_T>("UseProgram");
_GetIntegerv = GetProcAddress<GetIntegerv_T>("GetIntegerv"); _GetIntegerv = GetProcAddress<GetIntegerv_T>("GetIntegerv");
_GetActiveAttrib = GetProcAddress<GetActiveAttrib_T>("GetActiveAttrib");
_GetAttribLocation = GetProcAddress<GetAttribLocation_T>("GetAttribLocation");
_GetUniformIndices = GetProcAddress<GetUniformIndices_T>("GetUniformIndices");
_GetUniformLocation = GetProcAddress<GetUniformLocation_T>("GetUniformLocation");
_GetActiveUniformName = GetProcAddress<GetActiveUniformName_T>("GetActiveUniformName");
_GetActiveUniformsiv = GetProcAddress<GetActiveUniformsiv_T>("GetActiveUniformsiv");
_GetActiveUniform = GetProcAddress<GetActiveUniform_T>("GetActiveUniform");
} }
static void DeinitProcs() { static void DeinitProcs() {
_GetError = null; _GetError = null;
...@@ -60,6 +62,13 @@ namespace PoroCYon.FNAGLSL { ...@@ -60,6 +62,13 @@ namespace PoroCYon.FNAGLSL {
_DeleteProgram = null; _DeleteProgram = null;
_UseProgram = null; _UseProgram = null;
_GetIntegerv = null; _GetIntegerv = null;
_GetActiveAttrib = null;
_GetAttribLocation = null;
_GetUniformIndices = null;
_GetUniformLocation = null;
_GetActiveUniformName = null;
_GetActiveUniformsiv = null;
_GetActiveUniform = null;
} }
delegate GLenum GetError_T(); delegate GLenum GetError_T();
...@@ -99,9 +108,13 @@ namespace PoroCYon.FNAGLSL { ...@@ -99,9 +108,13 @@ namespace PoroCYon.FNAGLSL {
delegate void GetShaderInfoLog_T(GLuint sh, GLsizei maxl, GLsizei* len, delegate void GetShaderInfoLog_T(GLuint sh, GLsizei maxl, GLsizei* len,
GLchar* infolog); GLchar* infolog);
static GetShaderInfoLog_T _GetShaderInfoLog; static GetShaderInfoLog_T _GetShaderInfoLog;
public static void GetShaderInfoLog(GLuint sh, GLsizei maxl, public static string GetShaderInfoLog(GLuint sh, GLsizei maxl) {
GLsizei* len, GLchar* infolog) { GLchar[] logbuf = new GLchar[maxl];
_GetShaderInfoLog(sh, maxl, len, infolog); GLsizei len = 0;
fixed (GLchar* logp = logbuf) {
_GetShaderInfoLog(sh, maxl, &len, logp);
return new String(logp, 0, len, Encoding.UTF8);
}
} }
delegate void AttachShader_T(GLuint pr, GLuint sh); delegate void AttachShader_T(GLuint pr, GLuint sh);
...@@ -127,9 +140,13 @@ namespace PoroCYon.FNAGLSL { ...@@ -127,9 +140,13 @@ namespace PoroCYon.FNAGLSL {
delegate void GetProgramInfoLog_T(GLuint pr, GLsizei maxl, delegate void GetProgramInfoLog_T(GLuint pr, GLsizei maxl,
GLsizei* len, GLchar* infolog); GLsizei* len, GLchar* infolog);
static GetProgramInfoLog_T _GetProgramInfoLog; static GetProgramInfoLog_T _GetProgramInfoLog;
public static void GetProgramInfoLog(GLuint prgm, GLsizei maxl, public static string GetProgramInfoLog(GLuint prgm, GLsizei maxl) {
GLsizei* len, GLchar* infolog) { GLchar[] logbuf = new GLchar[maxl];
_GetProgramInfoLog(prgm, maxl, len, infolog); GLsizei len = 0;
fixed (GLchar* logp = logbuf) {
_GetProgramInfoLog(prgm, maxl, &len, logp);
return new String(logp, 0, len, Encoding.UTF8);
}
} }
delegate void DeleteShader_T(GLuint sh); delegate void DeleteShader_T(GLuint sh);
...@@ -152,6 +169,138 @@ namespace PoroCYon.FNAGLSL { ...@@ -152,6 +169,138 @@ namespace PoroCYon.FNAGLSL {
_GetIntegerv(name, parm); _GetIntegerv(name, parm);
return parm[0]; return parm[0];
} }
// TODO:
const int NAMEBUF_MAX_LEN = 64;
delegate void GetActiveAttrib_T(GLuint prgm, GLuint idx, GLsizei bufSize,
GLsizei* len, GLint* size, GLenum* type, GLchar* name);
static GetActiveAttrib_T _GetActiveAttrib;
public static void GetActiveAttrib(GLuint prgm, GLuint index,
out GLint size, out GLSLType type, out string name) {
GLchar* namebuf = stackalloc GLchar[NAMEBUF_MAX_LEN];
GLsizei namelen = 0;
size = 0;
GLenum _typ = 0;
fixed (GLint* psize = &size) {
_GetActiveAttrib(prgm, index,
(GLsizei)(NAMEBUF_MAX_LEN*sizeof(GLchar)),
&namelen, psize, &_typ, namebuf);
}
name = new String(namebuf, 0, namelen, Encoding.UTF8);
type = (GLSLType)_typ;
}
delegate GLint GetAttribLocation_T(GLuint prgm, GLchar* name);
static GetAttribLocation_T _GetAttribLocation;
public static GLint GetAttribLocation(GLuint prgm, string name) {
byte[] blargh = Encoding.UTF8.GetBytes(name);
fixed (byte* bb = blargh) {
return _GetAttribLocation(prgm, (GLchar*)bb);
}
}
delegate void GetUniformIndices_T(GLuint prgm, GLsizei unifCnt,
GLchar** unifNames, GLuint* unifIdxs);
static GetUniformIndices_T _GetUniformIndices;
public static void GetUniformIndices(GLuint prgm,
string[] names, GLuint[] idxs) {
if (names == null) throw new ArgumentNullException("names");
if (idxs == null) throw new ArgumentNullException("idxs" );
if (names.Length != idxs.Length) throw new ArgumentException("#names != #idxs");
// marshal the string array...
// convert all the string to utf8
int totallen = 0;
byte[][] bytes = new byte[names.Length][];
for (int i = 0; i < names.Length; ++i) {
bytes[i] = Encoding.UTF8.GetBytes(names[i]);
totallen += bytes[i].Length;
}
// rearrange pointer crap to that glGetUniformIndices can read it
byte[] bytesbytes = new byte[totallen];
GLchar*[] ptrs = new GLchar*[names.Length];
fixed (byte* bbp = bytesbytes) {
int totalidx = 0;
for (int i = 0; i < names.Length; ++i) {
Array.Copy(bytes[i], 0, bytesbytes, totalidx, bytes[i].Length);
ptrs[i] = (GLchar*)&bbp[totalidx];
totalidx += bytes[i].Length;
}
// now we can actually call the function
fixed (GLchar** strp = ptrs) {
fixed (GLuint* idxp = idxs) {
_GetUniformIndices(prgm, names.Length, strp, idxp);
}
}
}
}
delegate void GetActiveUniformName_T(GLuint prgm, GLuint unifIdx,
GLsizei bufSize, GLsizei* length, GLchar* unifName);
static GetActiveUniformName_T _GetActiveUniformName;
public static string GetActiveUniformName(GLuint prgm, GLuint unifIdx) {
GLchar* namebuf = stackalloc GLchar[NAMEBUF_MAX_LEN];
GLsizei namelen = 0;
_GetActiveUniformName(prgm, unifIdx,
(GLsizei)(NAMEBUF_MAX_LEN*sizeof(GLchar)),
&namelen, namebuf);
return new String(namebuf, 0, namelen, Encoding.UTF8);
}
delegate void GetActiveUniformsiv_T(GLuint prgm, GLsizei unifCnt,
GLuint* unifIdxs, GLenum pname, GLint* parms);
static GetActiveUniformsiv_T _GetActiveUniformsiv;
public static void GetActiveUniformsiv(GLuint prgm,
GLuint[] unifIdxs, GLenum pname, GLint[] parms) {
if (unifIdxs == null) throw new ArgumentNullException("unifIdxs");
if (parms == null) throw new ArgumentNullException("parms" );
if (unifIdxs.Length != parms.Length) throw new ArgumentException("#unifIdxs != #parms");
fixed (GLuint* idxs = unifIdxs) {
fixed (GLint* ps = parms) {
_GetActiveUniformsiv(prgm, parms.Length, idxs, pname, ps);
}
}
}
delegate void GetActiveUniform_T(GLuint prgm, GLuint idx, GLsizei bufSize,
GLsizei* length, GLint* size, GLenum* type, GLchar* name);
static GetActiveUniform_T _GetActiveUniform;
public static void GetActiveUniform(GLuint prgm, GLuint idx,
out GLint size, out GLSLType type, out string name) {
GLchar* namebuf = stackalloc GLchar[NAMEBUF_MAX_LEN];
GLsizei namelen = 0;
size = 0;
GLenum _typ = 0;
fixed (GLint* psize = &size) {
_GetActiveUniform(prgm, idx,
(GLsizei)(NAMEBUF_MAX_LEN*sizeof(GLchar)),
&namelen, psize, &_typ, namebuf);
}
name = new String(namebuf, 0, namelen, Encoding.UTF8);
type = (GLSLType)_typ;
}
delegate GLint GetUniformLocation_T(GLuint prgm, GLchar* name);
static GetUniformLocation_T _GetUniformLocation;
public static GLint GetUniformLocation(GLuint prgm, string name) {
if (name == null) throw new ArgumentNullException("name");
byte[] bytes = Encoding.UTF8.GetBytes(name);
fixed (byte* bp = bytes) {
return _GetUniformLocation(prgm, (GLchar*)bp);
}
}
// TODO: glUniform functions
} }
} }
...@@ -62,11 +62,14 @@ class TestGame : Game { ...@@ -62,11 +62,14 @@ class TestGame : Game {
glsl = new GLSLEffect(GraphicsDevice, new Dictionary<GLSLPurpose, string>() { glsl = new GLSLEffect(GraphicsDevice, new Dictionary<GLSLPurpose, string>() {
{ GLSLPurpose.VertexShader , { GLSLPurpose.VertexShader ,
"#version 430 core\n"+ "#version 410 core\n"+
"\n"+
"in vec3 in_pos;\n"+ "in vec3 in_pos;\n"+
"in vec4 in_col;\n"+ "in vec4 in_col;\n"+
"in vec2 in_texcoord;\n"+ "in vec2 in_texcoord;\n"+
"\n"+
"out vec2 out_texcoord;\n"+ "out vec2 out_texcoord;\n"+
"\n"+
"void main() {\n"+ "void main() {\n"+
" gl_Position = vec4(in_pos.x, in_pos.y, in_pos.z, 1.0);\n"+ " gl_Position = vec4(in_pos.x, in_pos.y, in_pos.z, 1.0);\n"+
" out_texcoord = in_texcoord;\n"+ " out_texcoord = in_texcoord;\n"+
...@@ -79,22 +82,35 @@ class TestGame : Game { ...@@ -79,22 +82,35 @@ class TestGame : Game {
"}\n"*/ "}\n"*/
}, },
{ GLSLPurpose.FragmentShader, { GLSLPurpose.FragmentShader,
"#version 430 core\n"+ "#version 330 core\n"+
"\n"+
"uniform float fGlobalTime;\n"+
"uniform vec2 v2Resolution;\n"+
"\n"+
"layout(location = 0) out vec4 C;\n"+ "layout(location = 0) out vec4 C;\n"+
"vec4 plas(vec2 v) {\n"+ "\n"+
" float c = 0.5 + sin(v.x * 10.0) + cos(sin(v.y) * 20.0);\n"+ "vec4 plas(float time, vec2 v) {\n"+
" return vec4(sin(c * 0.2 + 1), c * 0.15, cos(c * 0.1) * .25, 1.0);\n"+ " float c = 0.5 + sin(v.x * 10.0) + cos(sin(time + v.y) * 20.0);\n"+
" return vec4(sin(c * 0.2 + cos(time)), c * 0.15, cos(c * 0.1 + time / .4) * .25, 1.0);\n"+
"}\n"+ "}\n"+
"\n"+
"void main() {\n"+ "void main() {\n"+
/*" vec2 v2Resolution = vec2(1920.0, 1080.0);\n"+
" float fGlobalTime = 0.0;\n"+
"\n"+*/
" float pi = 4*atan(1);\n"+ " float pi = 4*atan(1);\n"+
" vec2 uv = vec2(gl_FragCoord.x/1920.0, gl_FragCoord.y/1080);\n"+ " vec2 uv = vec2(gl_FragCoord.x/v2Resolution.x, gl_FragCoord.y/v2Resolution.y);\n"+
" uv -= 0.5;\n"+ " uv -= 0.5;\n"+
" uv /= vec2(float(1920)/1080.0, 1.);\n"+ " uv /= vec2(v2Resolution.y/v2Resolution.x, 1.);\n"+
"\n"+
" vec2 m;\n"+ " vec2 m;\n"+
" m.x = atan(uv.x / uv.y) / pi;\n"+ " m.x = atan(uv.x / uv.y) / pi;\n"+
" m.y = 1 / length(uv) * .2;\n"+ " m.y = 1 / length(uv) * .2;\n"+
" float d = m.y;\n"+ " float d = m.y;\n"+
" vec4 t = plas(m * pi) / d;\n"+ " m.x += sin(fGlobalTime) * 0.1;\n"+
" m.y += fGlobalTime * 0.25;\n"+
"\n"+
" vec4 t = plas(fGlobalTime, m * pi) / d;\n"+
" C = clamp(t, 0.0, 1.0);\n"+ " C = clamp(t, 0.0, 1.0);\n"+
" /*gl_FragColor = vec4(0);*/\n"+ " /*gl_FragColor = vec4(0);*/\n"+
"}\n"} "}\n"}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment