Jump to content

Shader extension not supported


Slastraf
 Share

Go to solution Solved by SpiderPig,

Recommended Posts

Hi, I try to program a shader but for my use case I need a time value.
For this I tried to use the extension
 

#extension GL_EXT_shader_realtime_clock : enable // NOT ALLOWED

which is not allowed in the current setup.
image.thumb.png.225cbe6f8cf1184667c9f102d5af61bc.png
I dont know much about Vulcan or shaders, but could this be shipped with the next update ? That would make things a lot easier as I also try to make an animated (sprite) material which is not possible without a time value.

On the other hand , i tried passing it trough c++ directly using a uniform variable

uniform float u_Time;

which would lead to the following error.

 'non-opaque uniforms outside a block' : not allowed when using GLSL for Vulkan

Looking forward for a solution, as I said I am not experienced in shaders so maybe there already is.
 

Link to comment
Share on other sites

#version 450
#extension GL_GOOGLE_include_directive : enable
#extension GL_ARB_separate_shader_objects : enable
//#extension GL_EXT_shader_realtime_clock : enable // NOT ALLOWED
#include "../Base/Fragment.glsl"
#include "../Base/UniformBlocks.glsl"
#define PI 3.14159


float vDrop(vec2 uv,float t)
{
    uv.x = uv.x*128.0;						// H-Count
    float dx = fract(uv.x);
    uv.x = floor(uv.x);
    uv.y *= 0.05;							// stretch
    float o=sin(uv.x*215.4);				// offset
    float s=cos(uv.x*33.1)*.3 +.7;			// speed
    float trail = mix(95.0,35.0,s);			// trail length
    float yv = fract(uv.y + t*s + o) * trail;
    yv = 1.0/yv;
    yv = smoothstep(0.0,1.0,yv*yv);
    yv = sin(yv*PI)*(s*5.0);
    float d2 = sin(dx*PI);
    return yv*(d2*d2);
}


void main()
{
    //vec2 p = (vertexWorldPosition.xz - 0.5 * (vertexWorldPosition.xz+500.0)) / (vertexWorldPosition.xz-250.0);
vec2 p = (vertexWorldPosition.xz);
float d = length(p)+0.1;
	p = vec2(atan(p.x, p.y) / PI, 2.5 / d);
    float t =  CurrentTime*0.004;
    vec3 col = vec3(1.55,0.65,.225) * vDrop(p,t);	// red
    col += vec3(0.55,0.75,1.225) * vDrop(p,t+0.33);	// blue
    col += vec3(0.45,1.15,0.425) * vDrop(p,t+0.66);	// green
    outColor[0] = vec4(col*(d*d), 1.0);


    //Material material = materials[materialID];
    //outColor[0] = material.diffuseColor * color;
    //int textureID = GetMaterialTextureHandle(material, TEXTURE_DIFFUSE);    
    //if (textureID != -1) outColor[0] *= texture(texture2DSampler[textureID], texcoords.xy);

    //Camera distance fog
    //if ((entityflags & ENTITYFLAGS_NOFOG) == 0) ApplyDistanceFog(outColor[0].rgb, vertexWorldPosition.xyz, CameraPosition);
    
    //if ((RenderFlags & RENDERFLAGS_TRANSPARENCY) != 0)
    //{
    //    outColor[0].rgb *= outColor[0].a;
    //    //outColor[0].a = 1.0f;
    //} 
}

Hyperdrive shader based on Drop Tunnel by Del

image.thumb.png.3d98244289f00558a2afc30955bba1ca.png

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...