Shader Inputs
uniform vec3 iResolution; // viewport resolution (in pixels)
uniform float iTime; // shader playback time (in seconds)
uniform float iTimeDelta; // render time (in seconds)
uniform int iFrame; // shader playback frame
uniform float iChannelTime[4]; // channel playback time (in seconds)
uniform vec3 iChannelResolution[4]; // channel resolution (in pixels)
uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down), zw: click
uniform samplerXX iChannel0..3; // input channel. XX = 2D/Cube
uniform vec4 iDate; // (year, month, day, time in seconds)
uniform float iSampleRate; // sound sample rate (i.e., 44100)
uniform float iChannelTime[4]; // channel playback time (in seconds)
uniform vec3 iChannelResolution[4]; // channel resolution (in pixels)
uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down), zw: click
uniform float iSampleRate; // sound sample rate (i.e., 44100)
uniform float u_Elapsed; // The elapsed time in seconds
uniform vec2 u_WindowSize; // Window dimensions in pixels
#define iTime u_Elapsed //( varable iTime will get its value from the iStipper variable u_Elapsed )
#define iResolution u_WindowSize //( variable iResolution will get its value from iStripper variable u_WindowSize )
I have had a lot of trouble in past compiling attempts to convert shaders
which do not end with plain fragColor = .. but use say fragColor.xyz = ...
For example
https://www.shadertoy.com/view/WllfzS by gaz
#version 330
#extension GL_EXT_gpu_shader4 : enable
// added the version and open GL extension
// should be the first line of the shader
/////////////////////////////////////////////////////////////////////////////////
// from ShaderToy.com https://www.shadertoy.com/view/WllfzS
// Adapted for iStripper by WyldAnimal
uniform float u_Elapsed;
uniform vec2 u_WindowSize;
#define iTime u_Elapsed
#define iResolution u_WindowSize
/////////////////////////////////////////////////////////////////////////////////
float Scale;
float map(vec3 p)
{
float s=2.;
for(int i = 0; i < 4; i++) {
p=mod(p-1.,2.)-1.;
float r2=1.2/dot(p,p);
p*=r2;
s*=r2;
}
Scale=log2(s);
p = abs(p)-0.8;
if (p.x < p.z) p.xz = p.zx;
if (p.y < p.z) p.yz = p.zy;
if (p.x < p.y) p.xy = p.yx;
return length(cross(p,normalize(vec3(0,.5,1))))/s-Scale*.0015;
}
/////////////////////////////////////////////////////////////////////////////////
// need to convert this from a void to a function and call it by adding
// a void main(void) { to the end of the shader
// what type of variable will the function return?, it is a color and needs to be a vec4
// change void to vec4
//void MainImage(out vec4 fragColor, in vec2 fragCoord) {
vec4 mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv=(2.*fragCoord-iResolution.xy)/iResolution.y;
vec3 p,
ro=vec3(1.,1.,iTime),
w=normalize(vec3(.1*sin(iTime*.5),.3,1)),
u=normalize(cross(w,vec3(cos(-iTime*.16),sin(-iTime*.16),0))),
rd=mat3(u,cross(u,w),w)*normalize(vec3(uv,2));
float h=0.,d,i;
for(i=1.;i<100.;i++)
{
p=ro+rd*h;
d=map(p);
if(d<.0001)break;
h+=d;
}
//fragColor.xyz=35.*vec3(vec3(.7,.9,.7)*cos(Scale*.3)+(cos(p.xyy)*.5+.5))/i;
fragColor=vec4(35.*vec3(vec3(.7,.9,.7)*cos(Scale*.3)+(cos(p.xyy)*.5+.5))/i,1.0);
/////////////////////////////////////////////////////////////////////////////////
//the function needs to return a value.
//it needs to be a vec4
//we will return the varable fragColor
return fragColor;
}
/////////////////////////////////////////////////////////////////////////////////
void main(void) { // this will be run for every pixel of gl_FragCoord.xy
vec4 fragColor = vec4(1.0); // initialize variable fragColor as a vec4
vec4 cc = mainImage(fragColor, gl_FragCoord.xy); // call function mainImage and assign the return vec4 to cc
gl_FragColor = vec4(cc); // set the pixel to the value of vec4 cc
}
download it here
https://virtuastripper.net/Shaders/WllfzS.fsh
and a Variant here
https://virtuastripper.net/Shaders/WllfzS-B.fsh
gl_FragColor = vec4(cc) * gl_Color;
as that would use the values of any Color: or Opacity: clauses (and any Animate clauses applied to these properties) appearing in the Sprite, Quad or other node invoking the shader in the .scn file.
header #version 330 to
something lower like #version 120 in order to make @TheEmu 's supplement work.
0(77) : error C7616: global variable gl_Color is removed after version 140]
2022-10-18T11:46:27[] WARNING[*** Problematic Fragment shader source code ***]
2022-10-18T11:46:27[] WARNING[#version 330
sample scenes
https://virtuastripper.net/WA_ET_FractalGarden684.zip
sample images
https://virtuastripper.net/SceneImages/ET%20-%20FractalGarden684WA2.jpg
https://virtuastripper.net/SceneImages/ET%20-%20FractalGarden684WA3.jpg
https://virtuastripper.net/SceneImages/ET%20-%20FractalGarden684WA4.jpg
https://virtuastripper.net/SceneImages/ET%20-%20FractalGarden684WA5.jpg
https://virtuastripper.net/SceneImages/ET%20-%20FractalGarden684WA6.jpg
Thank you so much @EverthangForever. All the scenes work well for me.Merci, je vais essayer de continuer à utiliser @Wyldanimal méthode car elle préserve le😊
Its a shame we cannot find a workaround for @TheEmu 's * gl_Color; reference to suit higher OpenGL versions.
texture2D(texture0).rgba
uniform sampler2D texture0;
uniform vec2 textureSize0;
varying vec4 gl_TexCoord[];
varying vec4 texture2D(texture0) is texture0
varying vec4 texture2D(texture1) is texture1
varying vec4 texture2D(texture2) is texture2
texture2D(texture0).rgbto get the alpha of texture0
texture2D(texture0).a
gl_FragColor.a = gl_FragColor.a * texture2D(texture0).a
gl_FragColor = vec4(cc) * texture2D(texture0).rgba
gl_FragColor = gl_FragColor * texture2D(texture0).rgbato preserve the color and Alpha of the Sample passed to the shader
gl_FragColor = gl_FragColor * texture2D(texture0).rgbacan be simplified to this
gl_FragColor *= texture2D(texture0).rgba
vec4 RGBA0 = texture2D(texture0).rgba;
vec4 RGBA0 = texture2D(texture0).rgba;
vec4 RGBA1 = texture2D(texture1).rgba;
vec4 RGBA2 = texture2D(texture2).rgba;
RGBA0
gl_FragColor = vec4(cc) * gl_Color;becomes this
gl_FragColor = vec4(cc) * RGBA0;
gl_FragColor = vec4(cc) * RGBA0 * RGBA1;or this
gl_FragColor = vec4(cc) * RGBA0 * RGBA1 * RGBA2;
another way to do it would be to just create a new Variable and assign the rgba to that variable.
another way to do it would be to just create a new Variable and assign the rgba to that variable.
That would work, but with the severe limitation that the values could not be made to vary using animate: clauses in the .scn file. It would also introduce complications because values assigned to a uniform in a.scn file are "unscoped" in that they do not only apply to the node in which they are assigned their value so you either have to remember to reset them or use different names in each of your shaders (duplicating any shader that is used twice in a scene.)
(you could, I think, make them vary by using a vertex shader - but that adds another level of awkwardness).
That would work, but with the severe limitation that the values could not be made to vary using animate: clauses in the .scn file.
However, none of this behavior exists in newer versions of GLSL. You must supply your own vertex attributes, your own varyings and you pick between colors using the value of gl_FrontFacing. I actually explained this in more detail in a different question related to OpenGL ES 2.0, but the basic principle is the same.
Als ein Gratisnutzer von iStripper bist du nicht berechtigt Beiträge zu schreiben oder neue Topics zu starten.
Aber du hast Zugriff auf die grundlegenden Bereiche und kannst unsere Community kennen lernen