Ticket #3233: sprite_with_color_mul.2.patch
File sprite_with_color_mul.2.patch, 7.7 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/shaders/arb/foreground_overlay.fp
1 1 !!ARBfp1.0 2 2 3 TEX result.color, fragment.texcoord[0], texture[0], 2D; 3 PARAM colorMul = program.local[0]; 4 TEMP color; 5 TEX color, fragment.texcoord[0], texture[0], 2D; 6 MUL color, color, colorMul; 7 MOV result.color, color; 4 8 5 9 END -
binaries/data/mods/public/shaders/arb/foreground_overlay.xml
3 3 4 4 <vertex file="arb/foreground_overlay.vp"> 5 5 <stream name="pos"/> 6 6 <stream name="uv0"/> 7 7 </vertex> 8 8 9 9 <fragment file="arb/foreground_overlay.fp"> 10 <uniform name="baseTex" loc="0" type="sampler2D"/> 10 <uniform name="baseTex" loc="0" type="sampler2D"/> 11 <uniform name="colorMul" loc="0" type="vec4"/> 11 12 </fragment> 12 13 13 14 </program> -
binaries/data/mods/public/shaders/glsl/foreground_overlay.fs
1 1 #version 110 2 2 3 3 uniform sampler2D baseTex; 4 uniform vec4 colorMul; 4 5 varying vec2 v_tex; 5 6 6 7 void main() 7 8 { 8 gl_FragColor = texture2D(baseTex, v_tex) ;9 gl_FragColor = texture2D(baseTex, v_tex) * colorMul; 9 10 } -
binaries/data/mods/public/simulation/components/StatusBars.js
119 119 icon, 120 120 { "x": xoffset - iconSize/2, "y": yoffset }, 121 121 { "x": xoffset + iconSize/2, "y": yoffset + iconSize }, 122 offset 122 offset, 123 "255 255 255 255" 123 124 ); 124 125 xoffset += iconSize * 1.2; 125 126 } … … 142 143 "art/textures/ui/session/icons/"+type+"_bg.png", 143 144 { "x": -width/2, "y":yoffset }, 144 145 { "x": width/2, "y": height + yoffset }, 145 offset 146 offset, 147 "255 255 255 255" 146 148 ); 147 149 148 150 cmpOverlayRenderer.AddSprite( … … 149 151 "art/textures/ui/session/icons/"+type+"_fg.png", 150 152 { "x": -width/2, "y": yoffset }, 151 153 { "x": width*(amount - 0.5), "y": height + yoffset }, 152 offset 154 offset, 155 "255 255 255 255" 153 156 ); 154 157 155 158 yoffset += height * 1.2; … … 190 193 icon, 191 194 { "x": -rankSize/2 + xoffset, "y": -rankSize/2 + yoffset }, 192 195 { "x": rankSize/2 + xoffset, "y": rankSize/2 + yoffset }, 193 offset 196 offset, 197 "255 255 255 255" 194 198 ); 195 199 } 196 200 } -
source/graphics/Overlay.h
1 /* Copyright (C) 201 2Wildfire Games.1 /* Copyright (C) 2015 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify … … 136 136 struct SOverlaySprite 137 137 { 138 138 CTexturePtr m_Texture; 139 CColor m_Color; 139 140 CVector3D m_Position; // base position 140 141 float m_X0, m_Y0, m_X1, m_Y1; // billboard corner coordinates, relative to base position 141 142 }; -
source/renderer/OverlayRenderer.cpp
1 /* Copyright (C) 201 4Wildfire Games.1 /* Copyright (C) 2015 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify … … 622 622 shader->BindTexture(str_baseTex, sprite->m_Texture); 623 623 else 624 624 sprite->m_Texture->Bind(); 625 626 shader->Uniform(str_colorMul, sprite->m_Color); 625 627 626 628 CVector3D pos[4] = { 627 629 sprite->m_Position + right*sprite->m_X0 + up*sprite->m_Y0, -
source/simulation2/components/CCmpOverlayRenderer.cpp
1 /* Copyright (C) 201 2Wildfire Games.1 /* Copyright (C) 2015 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify … … 27 27 #include "graphics/TextureManager.h" 28 28 #include "renderer/Renderer.h" 29 29 30 #include "ps/CLogger.h" 31 30 32 class CCmpOverlayRenderer : public ICmpOverlayRenderer 31 33 { 32 34 public: … … 112 114 UpdateMessageSubscriptions(); 113 115 } 114 116 115 virtual void AddSprite(VfsPath textureName, CFixedVector2D corner0, CFixedVector2D corner1, CFixedVector3D position )117 virtual void AddSprite(VfsPath textureName, CFixedVector2D corner0, CFixedVector2D corner1, CFixedVector3D position, std::string color) 116 118 { 119 CColor colorObj(1.0f, 1.0f, 1.0f, 1.0f); 120 if (!colorObj.ParseString(color, 1)) 121 LOGERROR("OverlayRenderer: Error parsing '%s'", color); 122 117 123 CTextureProperties textureProps(textureName); 118 124 119 125 SOverlaySprite sprite; … … 122 128 sprite.m_Y0 = corner0.Y.ToFloat(); 123 129 sprite.m_X1 = corner1.X.ToFloat(); 124 130 sprite.m_Y1 = corner1.Y.ToFloat(); 131 sprite.m_Color = colorObj; 125 132 126 133 m_Sprites.push_back(sprite); 127 134 m_SpriteOffsets.push_back(CVector3D(position)); -
source/simulation2/components/ICmpOverlayRenderer.cpp
1 /* Copyright (C) 201 0Wildfire Games.1 /* Copyright (C) 2015 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify … … 23 23 24 24 BEGIN_INTERFACE_WRAPPER(OverlayRenderer) 25 25 DEFINE_INTERFACE_METHOD_0("Reset", void, ICmpOverlayRenderer, Reset) 26 DEFINE_INTERFACE_METHOD_ 4("AddSprite", void, ICmpOverlayRenderer, AddSprite, VfsPath, CFixedVector2D, CFixedVector2D, CFixedVector3D)26 DEFINE_INTERFACE_METHOD_5("AddSprite", void, ICmpOverlayRenderer, AddSprite, VfsPath, CFixedVector2D, CFixedVector2D, CFixedVector3D, std::string) 27 27 END_INTERFACE_WRAPPER(OverlayRenderer) -
source/simulation2/components/ICmpOverlayRenderer.h
1 /* Copyright (C) 201 0Wildfire Games.1 /* Copyright (C) 2015 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify … … 48 48 * @param corner0,corner1 coordinates of sprite's corners, in world-space units oriented with the camera plane, 49 49 * relative to the sprite position. 50 50 * @param offset world-space offset of sprite position from the entity's base position. 51 * @param color multiply color of texture 51 52 */ 52 virtual void AddSprite(VfsPath textureName, CFixedVector2D corner0, CFixedVector2D corner1, CFixedVector3D offset ) = 0;53 virtual void AddSprite(VfsPath textureName, CFixedVector2D corner0, CFixedVector2D corner1, CFixedVector3D offset, std::string color = "255 255 255 255") = 0; 53 54 54 55 DECLARE_INTERFACE_TYPE(OverlayRenderer) 55 56 };