It looks like you're new here. If you want to get involved, click one of these buttons!
--!NEEDS:luashader/luashader.lua local tex_color=Texture.new("maps/color.png",false) local function makeEffect(name,vshader,fshader) local s=Shader.lua(vshader,fshader,0, { {name="vMatrix",type=Shader.CMATRIX,sys=Shader.SYS_WVP,vertex=true}, {name="fColor",type=Shader.CFLOAT4,sys=Shader.SYS_COLOR,vertex=false}, {name="fTexture",type=Shader.CTEXTURE,vertex=false}, {name="fTextureColor",type=Shader.CTEXTURE,vertex=false}, {name="fTextureInfo",type=Shader.CFLOAT4,sys=Shader.SYS_TEXTUREINFO,vertex=false}, {name="fTime",type=Shader.CFLOAT,sys=Shader.SYS_TIMER,vertex=false}, }, { {name="vVertex",type=Shader.DFLOAT,mult=2,slot=0,offset=0}, {name="vColor",type=Shader.DUBYTE,mult=4,slot=1,offset=0}, {name="vTexCoord",type=Shader.DFLOAT,mult=2,slot=2,offset=0}, }, { {name="fTexCoord",type=Shader.CFLOAT2}, } ) s.name=name return s end local effect =makeEffect("Custom", function (vVertex,vColor,vTexCoord) : Shader local vertex = hF4(vVertex,0.0,1.0) fTexCoord=vTexCoord return vMatrix*vertex end, function () : Shader -- How to read and copy pixel color from input texture (input by setContant) local frag = texture2D(fTextureColor, fTexCoord) return frag end ) effect:setConstant("fTextureColor", Shader.CTEXTURE,1,tex_color) local px = Pixel.new(1024,1024) px:setShader(effect) stage:addChild(px) |
Comments
https://wiki.giderosmobile.com/index.php/Mesh:setTexture
see also
https://forum.giderosmobile.com/discussion/8571/multiple-texture-slots-for-bitmap/p1
perhaps a texture can be directly assigned to the shader too, i'm not sure.
Likes: vitalitymobile
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Yeah, reading the Pixel setTexture function leads me to the question of how to get texture from slots in shader code. That may be a way to bind all needed textures to a Pixel instance.
https://wiki.gideros.rocks/index.php/Pixel:setTexture
https://wiki.gideros.rocks/index.php/Shader:setConstant may be what your are looking for?
Example:
For an extensive use of shaders you can have a look at the gideros sample 3D Horse or 3D Animation?
In your example, replace this:
Likes: vitalitymobile, MoKaLux
Likes: keszegh, MoKaLux