User Tools

Site Tools


en:examples:shaders:shader_on_an_object

This is an old revision of the document!


Shader on an Object

Assets

Code

orxObject_CreateFromConfig("DemoObject");

Config

[DemoObject]
Graphic = DemoGraphic
ShaderList = Shader
 
[DemoGraphic]
Texture = ship.png
 
[Shader]
ParamList = texture
Code = "
void main() {
 
    vec2 p = gl_TexCoord[0].xy;
    vec4 textureCol = texture2D(texture, p);
 
    gl_FragColor.rgb = textureCol.rgb;
    gl_FragColor.a = textureCol.a * (1.0 - p.y);
 
}"

Result

Note: this simple shader is only effective for a single image texture. For spritesheets, see this example instead.

en/examples/shaders/shader_on_an_object.1518583668.txt.gz · Last modified: 2018/02/14 00:47 (6 years ago) (external edit)