This shows you the differences between two versions of the page.
| Previous revision | |||
| — | en:examples:shaders:shader_on_an_object [2025/09/30 17:26 (6 weeks ago)] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Shader on an Object ====== | ||
| + | |||
| + | ===== Assets ===== | ||
| + | {{examples: | ||
| + | |||
| + | ===== Code ===== | ||
| + | |||
| + | < | ||
| + | orxObject_CreateFromConfig(" | ||
| + | </ | ||
| + | |||
| + | ===== 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, | ||
| + | |||
| + | gl_FragColor.rgb = textureCol.rgb; | ||
| + | gl_FragColor.a = textureCol.a * (1.0 - p.y); | ||
| + | |||
| + | }" | ||
| + | </ | ||
| + | |||
| + | ===== Result ===== | ||
| + | {{examples: | ||
| + | |||
| + | Note: this simple shader is only effective for a single image texture. For spritesheets, | ||
| + | |||