niektb Posted December 25, 2013 Report Share Posted December 25, 2013 Hello guys,I fancy programming some GLSL shaders in 0 A.D. but I don't know where to start.I checked the wiki but not much info was posted there.Which program should I use to create them and which version of GLSL is used in 0 A.D.?Do I need other stuff?Regards,Niek 1 Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted December 25, 2013 Report Share Posted December 25, 2013 For such questions, it's best to come on the #0ad-dev irc channel on Quakenet. People like Philip and historicbruno probably know everything about it. 1 Quote Link to comment Share on other sites More sharing options...
ProvencalLeGaullois Posted December 25, 2013 Report Share Posted December 25, 2013 If you are using OpenGL :OpenGL Shading Language "the orange book". It seems you can download for free the second edition, if your not to far of an university you can look at their math/computer library, mine have the book...nvidia GPU gems are often cited to have some good examples. Also you canf ound some publications about some shaders... I am myself learning and writing an opengl application using shaders, so if you have some good resources plz share it Quote Link to comment Share on other sites More sharing options...
historic_bruno Posted December 25, 2013 Report Share Posted December 25, 2013 A few 0 A.D.-specific resources to get you started: 0 A.D. Modding Guide - explains about modding the game and mentions some popular tools Material system - technical details about the game's shader and material system, including what versions we use. No doubt it won't answer every question, then you'll have to delve into the engine source code or ask someone Personally, I'm on Windows most of the time, and I just use Notepad++ to modify the shaders. A tool that can be priceless in debugging your work is gDEBugger. Quote Link to comment Share on other sites More sharing options...
niektb Posted December 27, 2013 Author Report Share Posted December 27, 2013 I noticed on the fly that we still use OpenGL 2.1. Why don't we use a newer version like 4.2? Quote Link to comment Share on other sites More sharing options...
wraitii Posted December 27, 2013 Report Share Posted December 27, 2013 4.2 is not supported by every graphic card (faaaar from it, actually), 2.1 is a version that is, on the other hand, pretty universally supported. Quote Link to comment Share on other sites More sharing options...
niektb Posted December 27, 2013 Author Report Share Posted December 27, 2013 Any tools to display the result quickly? I used Shader Designer, but it seems to me that these shaders won't work in the game. Quote Link to comment Share on other sites More sharing options...
ProvencalLeGaullois Posted December 28, 2013 Report Share Posted December 28, 2013 there is some software for shaders dev. Saddly (for me) most of them are written for windows... I read some time that RenderMonkey (ATI) is a very good software. I never used RenderMonkey, I don't know if it's still up to date or not, if it's good for opengl and/or directx... When I tried for myself to found a software, I found some other (on sourceforge iirc) who looked interesting but all for windows... So I'm writing my own application, it will never as good as RenderMonkey or such (so far).... but it will enough for my needs. 1 Quote Link to comment Share on other sites More sharing options...
niektb Posted December 28, 2013 Author Report Share Posted December 28, 2013 Rendermonkey is EOL. Last release was in 2008. But I just came across OpenSceneGraph, which looks very interesting.http://www.openscenegraph.org/It is fully cross-platform and it looks like being maintained and used. Plenty of resources as well. Quote Link to comment Share on other sites More sharing options...
ProvencalLeGaullois Posted December 28, 2013 Report Share Posted December 28, 2013 (edited) I'm using openscenegraph too. Saddly most of the documentation on the web are outdated, there is two books I have them at university. You have to use the mailling list to get some help. OSG is a 3D engine, so you can use shaders and write a program, but there is no tools for shaders dev (for what I know). OSG is used for virtual environment, not for games. The reason of why is not use in games isn't really clear for me, some peoples say scene graph is not good for games, but I read one time that was true ~20 years ago but not anymore today. If you are looking for a 3D engine which use a lot shaders (with opengl) peek a look at Horde3D.(hope my english isn't too crappy because I'm tired)edit :: when I send to the OSG mailling list a mail about the lack of documentation, they told me to study the examples who come with OSG. Edited December 28, 2013 by ProvencalLeGaullois Quote Link to comment Share on other sites More sharing options...
feneur Posted December 28, 2013 Report Share Posted December 28, 2013 Any tools to display the result quickly? I used Shader Designer, but it seems to me that these shaders won't work in the game.Actually you shouldn't need to use a specific tool just to display it, Pyrogenesis should automatically detect that a file has been changed and update the display. Just open up Atlas and add an object using the shader you're working on and save the file when you want to see the result. Quote Link to comment Share on other sites More sharing options...
niektb Posted December 29, 2013 Author Report Share Posted December 29, 2013 I tried to implement a simple post-proc shader but nothing happened at all in the Atlas! Even the other shaders didn't change anything. (I'm sorry. I'm unable to upload my shader due to permission restrictions.) Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted December 29, 2013 Report Share Posted December 29, 2013 Did you try in game too? Some options are disabled in Atlas. 1 Quote Link to comment Share on other sites More sharing options...
feneur Posted December 29, 2013 Report Share Posted December 29, 2013 I tried to implement a simple post-proc shader but nothing happened at all in the Atlas! Even the other shaders didn't change anything. (I'm sorry. I'm unable to upload my shader due to permission restrictions.)We could enable more file formats, but I'm generally against it - it's better if people put their files in ZIPs/7zips/GZs/some compressed format as that takes up less space on the servers/is quicker for people to download Quote Link to comment Share on other sites More sharing options...
Josh Posted December 30, 2013 Report Share Posted December 30, 2013 AMD CodeXL is a nice Linux/Windows debugging tool. Quote Link to comment Share on other sites More sharing options...
niektb Posted December 30, 2013 Author Report Share Posted December 30, 2013 (edited) Though I pick my own PostProc effect, the xml-file says that the default is selected. Same for other effects. Edited December 30, 2013 by niektb Quote Link to comment Share on other sites More sharing options...
niektb Posted January 29, 2014 Author Report Share Posted January 29, 2014 (edited) It took a while before I started again on programming shaders.This time I tried creating a FXAA-shader. No luck however:Does anybody has some thoughts on this?I tried modifying the following shader:https://code.google.com/p/processing/source/browse/trunk/processing/java/libraries/opengl/examples/Shaders/FXAA/data/fxaa.glsl?r=9668Some background information on FXAA:http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdfThe code:fxaa.xml<?xml version="1.0" encoding="utf-8"?><program type="glsl"> <vertex file="glsl/hdr.vs"> <stream name="pos"/> <stream name="uv0"/> <attrib name="a_vertex" semantics="gl_Vertex"/> <attrib name="a_uv0" semantics="gl_MultiTexCoord0"/> </vertex> <fragment file="glsl/fxaa.fs"/></program>fxaa.fs#version 120uniform sampler2D renderedTex;varying vec2 v_tex;void main() { // The parameters are hardcoded for now, but could be // made into uniforms to control fromt he program. float FXAA_SPAN_MAX = 8.0; float FXAA_REDUCE_MUL = 1.0/8.0; float FXAA_REDUCE_MIN = (1.0/128.0); vec3 rgbNW = texture2D(renderedTex, v_tex + (vec2(-1.0, -1.0) )).rgb; vec3 rgbNE = texture2D(renderedTex, v_tex + (vec2(+1.0, -1.0))).rgb; vec3 rgbSW = texture2D(renderedTex, v_tex + (vec2(-1.0, +1.0))).rgb; vec3 rgbSE = texture2D(renderedTex, v_tex + (vec2(+1.0, +1.0))).rgb; vec3 rgbM = texture2D(renderedTex, v_tex).rgb; vec3 luma = vec3(0.299, 0.587, 0.114); float lumaNW = dot(rgbNW, luma); float lumaNE = dot(rgbNE, luma); float lumaSW = dot(rgbSW, luma); float lumaSE = dot(rgbSE, luma); float lumaM = dot( rgbM, luma); float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); vec2 dir; dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN); float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce); dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)); vec3 rgbA = (1.0/2.0) * ( texture2D(renderedTex, v_tex + dir * (1.0/3.0 - 0.5)).rgb + texture2D(renderedTex, v_tex + dir * (2.0/3.0 - 0.5)).rgb); vec3 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * ( texture2D(renderedTex, v_tex + dir * (0.0/3.0 - 0.5)).rgb + texture2D(renderedTex, v_tex + dir * (3.0/3.0 - 0.5)).rgb); float lumaB = dot(rgbB, luma); if((lumaB < lumaMin) || (lumaB > lumaMax)){ gl_FragColor.rgb=rgbA; } else { gl_FragColor.rgb=rgbB; } gl_FragColor.a = 1.0;}fxaa.zipfxaa.zip Edited January 29, 2014 by niektb Quote Link to comment Share on other sites More sharing options...
niektb Posted March 13, 2014 Author Report Share Posted March 13, 2014 An interesting announcement:http://richg42.blogspot.nl/2014/01/vogl-opengl-tracerdebugger-bonus-content.html?showComment=1389950449081#c343074267754586249Valve has released a OpenGL debugger for Linux and made it opensource:https://github.com/ValveSoftware/vogl 1 Quote Link to comment Share on other sites More sharing options...
Stan` Posted March 13, 2014 Report Share Posted March 13, 2014 Did you make any improvement on your shader ? Quote Link to comment Share on other sites More sharing options...
niektb Posted March 13, 2014 Author Report Share Posted March 13, 2014 Did you make any improvement on your shader ?No, my latest result was the first image you encounter when you scroll to the top. It discouraged me to go any further. The problem is that I have no idea what input I get from the engine and what I should send back. Quote Link to comment Share on other sites More sharing options...
Stan` Posted March 13, 2014 Report Share Posted March 13, 2014 Maybe Iron Nerd may help you is starting to get involved in graphical programmation stuff ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.