Michael_Chang Posted October 6, 2012 Report Posted October 6, 2012 So I don't know whether or not this exists yet, but does anyone know how to create chrome/metallic dynamic reflections for aircrafts? i know ramzzess and danklau have done it, but after investigating with both of them, it turns out they can't be done for big parts like wings and fuselage. does anyone know a system that works with fuselage parts that will create dynamic reflections that are clear and sharp? Quote
Ben Russell Posted October 6, 2012 Report Posted October 6, 2012 Got a link to some video of Dan and Ramzzes work? Quote
Michael_Chang Posted October 6, 2012 Author Report Posted October 6, 2012 Got a link to some video of Dan and Ramzzes work?well dan used this object design to make it happen, his chrome engine rims rotate with the pitch of the plane so that it looks like the reflections,ramzzess's 777 uses a cockpit object htat moves back and forth to simulate reflections, si it's actually object based, not texture based Quote
Michael_Chang Posted October 6, 2012 Author Report Posted October 6, 2012 also, is that you? how was that done???? Quote
Peter T. Posted October 7, 2012 Report Posted October 7, 2012 (edited) i asked him earlier, about the same question, he gave me a great answer!-googlewell, i extensively searched around, but i cant find anything, and even i trie to download GLSL shader samples and tried to implement it to x-plane...i failed i wanted this kind of things so my windows in my airport buildings can be reflective.....maybe his reply was like that because he wanted to keep it a secret? like KFC's secret recipe Edited October 7, 2012 by Peter T. 1 Quote
Ben Russell Posted October 7, 2012 Report Posted October 7, 2012 (edited) If I can do it with Google, so can you. Edited October 7, 2012 by Ben Russell 1 Quote
Jordan P. Posted October 7, 2012 Report Posted October 7, 2012 I pretty sure if you can i probably can't because i am a young teen. So if anyone finds something please enlighten me? Quote
Ben Russell Posted October 7, 2012 Report Posted October 7, 2012 Rubbish.http://www.wired.com/threatlevel/2012/03/zero-days-for-chrome/ Quote
Jordan P. Posted October 7, 2012 Report Posted October 7, 2012 Oh sorry that came out wrong i meant on this subject i tried for a couple days now and couldn't find it. So i thought since adults are a bit better at serching (because they have experience) then they might find it faster but i will look again.Thanks for the PUSH in the right direction - Remlap - Quote
Michael_Chang Posted October 7, 2012 Author Report Posted October 7, 2012 but if you've managed to do it, why not share? it's obvious that if we managed to bring this into x-plane that the system would be a lot nicer Quote
Ben Russell Posted October 8, 2012 Report Posted October 8, 2012 I have already shared more than you ever will.http://forums.x-plane.org/index.php?showtopic=53783 1 Quote
Michael_Chang Posted October 8, 2012 Author Report Posted October 8, 2012 um okay... never mind then, i'll go ask someone else Quote
Ben Russell Posted October 8, 2012 Report Posted October 8, 2012 Give a man a fish and he'll eat for a day.Teach a man to fish... Quote
Goran_M Posted October 8, 2012 Report Posted October 8, 2012 MichaelAdding reflections is not a matter of textures.The reflections are "shaders" which can only be coded. Quote
Peter T. Posted October 8, 2012 Report Posted October 8, 2012 @Ben....thats the exact same quote that Vonhinx gave to me...when i asked him about animation...Give a man a fish and he'll eat for a day.Teach a man to fish, and he will feed himself for a lifetime....something like that Quote
Ben Russell Posted October 8, 2012 Report Posted October 8, 2012 I have provided a full link to working source code that can be used in an XPL file.I have published Gizmo, allowing use of shaders via Lua script. Quote
Michael_Chang Posted October 8, 2012 Author Report Posted October 8, 2012 it's not that i'm asking you to create it for me, i would like to learn! although i can't access the link for obvious reasons Quote
Ben Russell Posted October 8, 2012 Report Posted October 8, 2012 #ifndef __XGL_SHADER__#define __XGL_SHADER__/*#if IBM#include "GL/glu.h"#include "GL/glext.h"#else#include <OpenGL/glu.h>#include <OpenGL/glext.h>#endif*///usefull STL classes//#include "X_STL.h"#define printOpenGLError() this->printOglError(__FILE__, __LINE__)class XGLShader{ public: int compileShaders( const char *shdrVertex, const char *shdrFragment ); void enable(); void disable(); void setUniFloat( const char *name, float fV ); GLhandleARB sp; // <-- shaders handle for openGL. //private: int validShader; //will only set to 1 if the compile succeeds. controls enable disable logic too. void printOglError( char *file, int line ); void printInfoLog(GLhandleARB obj); GLint getUniLoc(GLhandleARB program, const GLcharARB *name); protected:};#endifvoid XGLShader::printOglError( char *file, int line ){GLenum glErr;int retCode = 0;char *err;// returns 1 if an OpenGL error occurred, 0 otherwise. glErr = glGetError();while (glErr != GL_NO_ERROR) {err = (char*)gluErrorString(glErr);fprintf(stderr,"file: %s \n line: %d \n glError: %s\n",file,line,err);retCode = 1;glErr = glGetError();}//return retCode};void XGLShader::printInfoLog(GLhandleARB obj){int infologLength = 0;int charsWritten = 0;GLcharARB *infoLog;printOpenGLError(); // Check for OpenGL errorsglGetObjectParameterivARB(obj, GL_OBJECT_INFO_LOG_LENGTH_ARB,(GLint*)&infologLength);printOpenGLError(); // Check for OpenGL errorsif (infologLength > 0){infoLog = (GLcharARB*)malloc(infologLength);if (infoLog == NULL){printf("ERROR: Could not allocate InfoLog buffer\n");exit(1);}glGetInfoLogARB(obj, infologLength, (GLint*)&charsWritten, infoLog);printf("InfoLog:\n%s\n\n", infoLog);free(infoLog);}printOpenGLError(); // Check for OpenGL errors}GLint XGLShader::getUniLoc(GLhandleARB program, const GLcharARB *name){GLint loc;loc = glGetUniformLocationARB(program, name);if (loc == -1)printf("No such uniform named \"%s\"\n", name);printOpenGLError(); // Check for OpenGL errorsreturn loc;}int XGLShader::compileShaders( const char *shdrVertex, const char *shdrFragment ){GLhandleARB shdrVS, shdrFS;//, shdrProg; // handles to objectsGLint vertCompiled, fragCompiled; // status valuesGLint linked;// Create a vertex shader object and a fragment shader objectshdrVS = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);shdrFS = glCreateShaderObjectARB(GL_FRAGMENT_SHADER);// Load source code strings into shaders glShaderSourceARB(shdrVS, 1, &shdrVertex, NULL);glShaderSourceARB(shdrFS, 1, &shdrFragment, NULL);// Compile the shdr vertex shader and print out// the compiler log file.glCompileShaderARB(shdrVS);printOpenGLError(); // Check for OpenGL errorsglGetObjectParameterivARB(shdrVS,GL_OBJECT_COMPILE_STATUS_ARB, &vertCompiled);this->printInfoLog(shdrVS);// Compile the shdr vertex shader and print out// the compiler log file.glCompileShaderARB(shdrFS);printOpenGLError(); // Check for OpenGL errorsglGetObjectParameterivARB(shdrFS,GL_OBJECT_COMPILE_STATUS_ARB, &fragCompiled);this->printInfoLog(shdrFS);if (!vertCompiled || !fragCompiled)return 0;// Create a program object and attach the two compiled shadersthis->sp = glCreateProgramObjectARB();glAttachObjectARB(this->sp, shdrVS);glAttachObjectARB(this->sp, shdrFS);// Link the program object and print out the info logglLinkProgramARB(this->sp);printOpenGLError(); // Check for OpenGL errorsglGetObjectParameterivARB(this->sp,GL_OBJECT_LINK_STATUS_ARB, &linked);this->printInfoLog(this->sp);if (!linked)return 0;// Install program object as part of current state//glUseProgramObjectARB(shdrProg);// Set up initial uniform values//glUniform3fARB( getUniLoc(shdrProg, "BrickColor"), 1.0, 0.3, 0.2);//glUniform3fARB( getUniLoc(shdrProg, "MortarColor"), 0.85, 0.86, 0.84);//glUniform2fARB( getUniLoc(shdrProg, "BrickSize"), 0.30, 0.15);//glUniform2fARB( getUniLoc(shdrProg, "BrickPct"), 0.90, 0.85);//glUniform3fARB( getUniLoc(shdrProg, "LightPosition"), 0.0, 0.0, 4.0); this->validShader = 1;return 1;}void XGLShader::setUniFloat( const char *name, float fV ){ glUniform1fARB( getUniLoc(this->sp, name), fV ); //printf("set uni float %s to: %f\n", name, fV);}void XGLShader::enable(){ if( this->validShader ){ //we need this in versions of x-plane prior to about 8.4 or 8.5 that did not have native shader support //glEnable(GL_VERTEX_PROGRAM_ARB); //glEnable(GL_FRAGMENT_PROGRAM_ARB); glUseProgramObjectARB( this->sp ); }else{ printf("XGLShader - tried to enable an invalid shader instance. Ignored.\n"); }}void XGLShader::disable(){ if( this->validShader ){ //we need this in versions of x-plane prior to about 8.4 or 8.5 that did not have native shader support //glDisable(GL_VERTEX_PROGRAM_ARB); //glDisable(GL_FRAGMENT_PROGRAM_ARB); glUseProgramObjectARB( 0 ); }} 1 Quote
Ben Russell Posted October 8, 2012 Report Posted October 8, 2012 Create a new plugin project.Import the code above.Use the code above to load and compile shader scripts of your choice.Create appropriate drawing callbacks that fire at the desired phase of X-Planes rendering system.Call the code above that enables shader drawing.Draw custom mesh loaded by your own code. (Eg: You'll need to write/find an OBJ8/FBX reader too.)Call the code above that disables shader drawing.Or, you can look into Gizmo, which has a shader API, and makes all of the above far far easier. Quote
tkyler Posted October 9, 2012 Report Posted October 9, 2012 (edited) it's not that i'm asking you to create it for me, i would like to learn! although i can't access the link for obvious reasonsThere are two aspects to the word 'learn' here:1.) Learn how to do it2.) Learn how its doneThese are different. #1 means pretty much being a full-fledge experienced programmer with higher education (read college) level of knowledge. #2 is simply satistying your curiosity...and that is much easier to explain. There are NO true reflections in X-Plane. There will be NO true reflections in x-plane for many many years to come. Dan Klaue and Roman have done what are called "hacks", albeit they are good hacks and the "ideas" for coming up with these hacks are diverse. The best reflective effect (as accepted in the industry) is done with OpenGL custom programming and with shaders and only BenR here has done it in XP thus far. X-Plane's shader engine presents lots of challenges and obstacles with implementing shader tech though...so until Laminar implments "reflections" on OBJs, I wouldn't expect to see it.-Tom Edited October 9, 2012 by tkyler 1 Quote
Dozer Posted October 9, 2012 Report Posted October 9, 2012 Give a man a fire and he'll be warm for a day.Set a man on fire and he'll be warm for the rest of his life.Nothing like OpenGL to keep your head warm! On all the many occasions (both of them) when I tried to learn to use it, I couldn't even compile the Hello World example. Quote
ShadowIGM Posted December 6, 2012 Report Posted December 6, 2012 what planes will tis plugin be compatable with? Quote
chris k Posted December 6, 2012 Report Posted December 6, 2012 Whatever plane the author has written this for.... I assume? This discussion a developer-side thing - not user-side per se. /me ducks. - CK. Quote
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.