aboutsummaryrefslogtreecommitdiff
path: root/client/shaders
Commit message (Collapse)AuthorAge
* Require 'waving = 3' in a nodedef to apply the liquid waving shader (#8418)Paramat2019-03-27
| | | | | | | | Makes the liquid waving shader per-nodedef like waving leaves/plants, instead of being applied to all liquids. Like the waving leaves/plants shaders, the liquid waving shader can also be applied to meshes and nodeboxes. Derived from a PR by t0ny2.
* Shaders: Fix comment line (#7668)xzcx2018-08-30
| | | Fixed comment as finalColorBlend() does not exist in the code base.
* Rewrite rendering engine (#6253)Vitaliy2017-10-31
| | | | | | | | | | | | * Clean draw_*() arguments * Split rendering core * Add anaglyph 3D * Interlaced 3D * Drop obsolete methods
* Shaders: Remove unused water surface shaderparamat2017-05-08
| | | | | | | | | | Also remove hardcoded MTGame node. The 'water surface shader' was duplicated shader code in preparation for intended new water surface shaders. For development purposes the MTGame node 'default:water_source' had it's top tile assigned to 'water surface shader'. Due to shader duplication this commit does not cause any change to shader behaviour.
* Fix fog weirdness (#5146)numberZero2017-01-31
|
* Add hardware node coloring. Includes:Dániel Juhász2017-01-23
| | | | | | - Increase ContentFeatures serialization version - Color property and palettes for nodes - paramtype2 = "color", "colored facedir" or "colored wallmounted"
* Shaders: Remove unnecessary 'if' statementsLars Hofhansl2016-12-24
| | | | | | Pull if GENERATE_NORMALMAPS == 1 into the template to avoid evaluating it for each fragment. Remove if (fogDistance != 0.0).
* Fog: Make fraction of visible distance at which fog starts configurableLars Hofhansl2016-12-07
| | | | | | Optimise the fetching of global settings 'camera_smoothing', 'cinematic' and 'cinematic_camera_smoothing'. Cache 'cam_smoothing'.
* Fix unexplained shader issue (glsl compiler bug??) (#4757)Rogier-52016-11-17
|
* Remove unused shader matrices. (#4723)lhofhansl2016-11-04
|
* Shaders: Remove special handling for liquids. (#4670)lhofhansl2016-10-26
|
* Shaders: Apply tone mapping before fog calculation.Lars Hofhansl2016-10-25
|
* Shaders: Harmonize Irrlicht and shader fog calculationsLars Hofhansl2016-10-24
|
* Use range-based fog instead of z-plane based.Lars Hofhansl2016-10-13
|
* Nodes shader: Decrease amplitude of waving leaves and plantsparamat2016-03-30
| | | | | | Fix initialisation of variable 'disp' Fix a few minor code style issues Add independent X motion combining 2 prime frequencies
* Replace CRLF with LF in shader filesest312016-03-25
|
* Shaders: fix fog not affecting opaque liquidsRealBadAngel2016-02-23
|
* Filmic HDR tone mappingRealBadAngel2016-02-09
|
* Cleanup selection mesh code, add shaders for halo and selection boxesRealBadAngel2016-02-08
|
* Speed up and make more accurate relief mappingRealBadAngel2015-12-10
| | | | using linear + binary search.
* Shaders: use triple-frequency waving for leaves and plantsparamat2015-09-07
|
* Remove use of engine sent texture tiling flags - theyre no longer neededRealBadAngel2015-08-20
|
* Add wielded (and CAOs) shaderRealBadAngel2015-07-21
|
* Fix relief mapping issuesRealBadAngel2015-07-16
|
* Shaders fixes and cleanup relief mapping code.RealBadAngel2015-07-02
|
* Bugfix: variable type mismatchRealBadAngel2015-06-28
|
* Add minimap featureRealBadAngel2015-06-27
|
* Remove textures vertical offset. Fix for area enabling parallax.RealBadAngel2015-06-21
|
* Automated whitespace error fix for last commitest312015-06-14
|
* Improved parallax mapping. Generate heightmaps on the fly.RealBadAngel2015-06-14
|
* Optimize bumpmapping mathematicsLoic Blot2015-01-16
| | | | | | OpenGL_vertex: * bufferize a duplicate calcul * Factorize vertexes
* Revert "Optimize bumpmapping mathematics"Craig Robbins2015-01-16
| | | | This reverts commit 148fffb0f23fa437c67639ff3cc69177fb71d76a.
* Optimize bumpmapping mathematicsLoic Blot2015-01-15
| | | | | | OpenGL_vertex: * bufferize a duplicate calcul * Factorize vertexes
* Restore finalColorBlend implementation in shaders.RealBadAngel2014-12-07
|
* Let lighting be done only CPU side. Remove finalColorBlend implementation ↵RealBadAngel2014-08-16
| | | | from shaders.
* Make faces shading correct for all possible modes.RealBadAngel2014-08-14
| | | | | Skip shading for lightsources and top of the nodes. Fixes liquid sources and flowing surfaces having different brightness.
* Faces shading fixesRealBadAngel2014-07-07
|
* Improved faces shading with and without shaders.RealBadAngel2014-06-17
|
* Unite nodes shaders.RealBadAngel2014-06-15
| | | | | | | Pass drawtype and material type to shaders. Move shaders generation to startup only. Allow assign shaders per tile. Initial code to support water surface shader.
* Fix invalid liquid lighting.RealBadAngel2014-04-16
|
* Normal maps generation on the fly.RealBadAngel2014-03-21
| | | | | Parallax mapping with slope information. Overriding normal maps.
* Optimize shaders code. Add settings at compile time.RealBadAngel2013-12-09
|
* Fix shaders on some GPUsNovatux2013-12-08
|
* Shaders rework.RealBadAngel2013-12-03
|
* Fix texture bumpmapping on some GPUsZeg92013-08-04
|
* Add texture bumpmapping feature.RealBadAngel2013-07-04
|
* Actually fix shader3 alpha this timekwolekr2013-04-27
|
* Transform alpha channel as well in shaderkwolekr2013-04-25
|
* Add option to use texture alpha channelkwolekr2013-04-23
|
* Fix new_style_waterPilzAdam2013-03-17
|
l opt">{ int endian = 0; // 0 for Little-Endian, 1 for Big-Endian int bitStream; long bytes; char array[BUFFER_SIZE]; // Local fixed size array vorbis_info *pInfo; OggVorbis_File oggFile; // Do a dumb-ass static string copy for old versions of ov_fopen // because they expect a non-const char* char nonconst[10000]; snprintf(nonconst, 10000, "%s", filepath.c_str()); // Try opening the given file //if(ov_fopen(filepath.c_str(), &oggFile) != 0) if(ov_fopen(nonconst, &oggFile) != 0) { infostream<<"Audio: Error opening "<<filepath<<" for decoding"<<std::endl; return NULL; } SoundBuffer *snd = new SoundBuffer; // Get some information about the OGG file pInfo = ov_info(&oggFile, -1); // Check the number of channels... always use 16-bit samples if(pInfo->channels == 1) snd->format = AL_FORMAT_MONO16; else snd->format = AL_FORMAT_STEREO16; // The frequency of the sampling rate snd->freq = pInfo->rate; // Keep reading until all is read do { // Read up to a buffer's worth of decoded sound data bytes = ov_read(&oggFile, array, BUFFER_SIZE, endian, 2, 1, &bitStream); if(bytes < 0) { ov_clear(&oggFile); infostream<<"Audio: Error decoding "<<filepath<<std::endl; return NULL; } // Append to end of buffer snd->buffer.insert(snd->buffer.end(), array, array + bytes); } while (bytes > 0); alGenBuffers(1, &snd->buffer_id); alBufferData(snd->buffer_id, snd->format, &(snd->buffer[0]), snd->buffer.size(), snd->freq); ALenum error = alGetError(); if(error != AL_NO_ERROR){ infostream<<"Audio: OpenAL error: "<<alErrorString(error) <<"preparing sound buffer"<<std::endl; } infostream<<"Audio file "<<filepath<<" loaded"<<std::endl; // Clean up! ov_clear(&oggFile); return snd; } struct PlayingSound { ALuint source_id; bool loop; }; class OpenALSoundManager: public ISoundManager { private: OnDemandSoundFetcher *m_fetcher; ALCdevice *m_device; ALCcontext *m_context; bool m_can_vorbis; int m_next_id; std::map<std::string, std::vector<SoundBuffer*> > m_buffers; std::map<int, PlayingSound*> m_sounds_playing; v3f m_listener_pos; public: bool m_is_initialized; OpenALSoundManager(OnDemandSoundFetcher *fetcher): m_fetcher(fetcher), m_device(NULL), m_context(NULL), m_can_vorbis(false), m_next_id(1), m_is_initialized(false) { ALCenum error = ALC_NO_ERROR; infostream<<"Audio: Initializing..."<<std::endl; m_device = alcOpenDevice(NULL); if(!m_device){ infostream<<"Audio: No audio device available, audio system " <<"not initialized"<<std::endl; return; } if(alcIsExtensionPresent(m_device, "EXT_vorbis")){ infostream<<"Audio: Vorbis extension present"<<std::endl; m_can_vorbis = true; } else{ infostream<<"Audio: Vorbis extension NOT present"<<std::endl; m_can_vorbis = false; } m_context = alcCreateContext(m_device, NULL); if(!m_context){ error = alcGetError(m_device); infostream<<"Audio: Unable to initialize audio context, " <<"aborting audio initialization ("<<alcErrorString(error) <<")"<<std::endl; alcCloseDevice(m_device); m_device = NULL; return; } if(!alcMakeContextCurrent(m_context) || (error = alcGetError(m_device) != ALC_NO_ERROR)) { infostream<<"Audio: Error setting audio context, aborting audio " <<"initialization ("<<alcErrorString(error)<<")"<<std::endl; alcDestroyContext(m_context); m_context = NULL; alcCloseDevice(m_device); m_device = NULL; return; } alDistanceModel(AL_EXPONENT_DISTANCE); infostream<<"Audio: Initialized: OpenAL "<<alGetString(AL_VERSION) <<", using "<<alcGetString(m_device, ALC_DEVICE_SPECIFIER) <<std::endl; m_is_initialized = true; } ~OpenALSoundManager() { infostream<<"Audio: Deinitializing..."<<std::endl; // KABOOM! // TODO: Clear SoundBuffers alcMakeContextCurrent(NULL); alcDestroyContext(m_context); m_context = NULL; alcCloseDevice(m_device); m_device = NULL; for (std::map<std::string, std::vector<SoundBuffer*> >::iterator i = m_buffers.begin(); i != m_buffers.end(); i++) { for (std::vector<SoundBuffer*>::iterator iter = (*i).second.begin(); iter != (*i).second.end(); iter++) { delete *iter; } (*i).second.clear(); } m_buffers.clear(); infostream<<"Audio: Deinitialized."<<std::endl; } void addBuffer(const std::string &name, SoundBuffer *buf) { std::map<std::string, std::vector<SoundBuffer*> >::iterator i = m_buffers.find(name); if(i != m_buffers.end()){ i->second.push_back(buf); return; } std::vector<SoundBuffer*> bufs; bufs.push_back(buf); m_buffers[name] = bufs; return; } SoundBuffer* getBuffer(const std::string &name) { std::map<std::string, std::vector<SoundBuffer*> >::iterator i = m_buffers.find(name); if(i == m_buffers.end()) return NULL; std::vector<SoundBuffer*> &bufs = i->second; int j = myrand() % bufs.size(); return bufs[j]; } PlayingSound* createPlayingSound(SoundBuffer *buf, bool loop, float volume) { infostream<<"OpenALSoundManager: Creating playing sound"<<std::endl; assert(buf); PlayingSound *sound = new PlayingSound; assert(sound); warn_if_error(alGetError(), "before createPlayingSound"); alGenSources(1, &sound->source_id); alSourcei(sound->source_id, AL_BUFFER, buf->buffer_id); alSourcei(sound->source_id, AL_SOURCE_RELATIVE, true); alSource3f(sound->source_id, AL_POSITION, 0, 0, 0); alSource3f(sound->source_id, AL_VELOCITY, 0, 0, 0); alSourcei(sound->source_id, AL_LOOPING, loop ? AL_TRUE : AL_FALSE); volume = MYMAX(0.0, volume); alSourcef(sound->source_id, AL_GAIN, volume); alSourcePlay(sound->source_id); warn_if_error(alGetError(), "createPlayingSound"); return sound; } PlayingSound* createPlayingSoundAt(SoundBuffer *buf, bool loop, float volume, v3f pos) { infostream<<"OpenALSoundManager: Creating positional playing sound" <<std::endl; assert(buf); PlayingSound *sound = new PlayingSound; assert(sound); warn_if_error(alGetError(), "before createPlayingSoundAt"); alGenSources(1, &sound->source_id); alSourcei(sound->source_id, AL_BUFFER, buf->buffer_id); alSourcei(sound->source_id, AL_SOURCE_RELATIVE, false); alSource3f(sound->source_id, AL_POSITION, pos.X, pos.Y, pos.Z); alSource3f(sound->source_id, AL_VELOCITY, 0, 0, 0); //alSourcef(sound->source_id, AL_ROLLOFF_FACTOR, 0.7); alSourcef(sound->source_id, AL_REFERENCE_DISTANCE, 30.0); alSourcei(sound->source_id, AL_LOOPING, loop ? AL_TRUE : AL_FALSE); volume = MYMAX(0.0, volume); alSourcef(sound->source_id, AL_GAIN, volume); alSourcePlay(sound->source_id); warn_if_error(alGetError(), "createPlayingSoundAt"); return sound; } int playSoundRaw(SoundBuffer *buf, bool loop, float volume) { assert(buf); PlayingSound *sound = createPlayingSound(buf, loop, volume); if(!sound) return -1; int id = m_next_id++; m_sounds_playing[id] = sound; return id; } int playSoundRawAt(SoundBuffer *buf, bool loop, float volume, v3f pos) { assert(buf); PlayingSound *sound = createPlayingSoundAt(buf, loop, volume, pos); if(!sound) return -1; int id = m_next_id++; m_sounds_playing[id] = sound; return id; } void deleteSound(int id) { std::map<int, PlayingSound*>::iterator i = m_sounds_playing.find(id); if(i == m_sounds_playing.end()) return; PlayingSound *sound = i->second; alDeleteSources(1, &sound->source_id); delete sound; m_sounds_playing.erase(id); } /* If buffer does not exist, consult the fetcher */ SoundBuffer* getFetchBuffer(const std::string name) { SoundBuffer *buf = getBuffer(name); if(buf) return buf; if(!m_fetcher) return NULL; std::set<std::string> paths; std::set<std::string> datas; m_fetcher->fetchSounds(name, paths, datas); for(std::set<std::string>::iterator i = paths.begin(); i != paths.end(); i++){ loadSoundFile(name, *i); } for(std::set<std::string>::iterator i = datas.begin(); i != datas.end(); i++){ loadSoundData(name, *i); } return getBuffer(name); } // Remove stopped sounds void maintain() { verbosestream<<"OpenALSoundManager::maintain(): " <<m_sounds_playing.size()<<" playing sounds, " <<m_buffers.size()<<" sound names loaded"<<std::endl; std::set<int> del_list; for(std::map<int, PlayingSound*>::iterator i = m_sounds_playing.begin(); i != m_sounds_playing.end(); i++) { int id = i->first; PlayingSound *sound = i->second; // If not playing, remove it { ALint state; alGetSourcei(sound->source_id, AL_SOURCE_STATE, &state); if(state != AL_PLAYING){ del_list.insert(id); } } } if(del_list.size() != 0) verbosestream<<"OpenALSoundManager::maintain(): deleting " <<del_list.size()<<" playing sounds"<<std::endl; for(std::set<int>::iterator i = del_list.begin(); i != del_list.end(); i++) { deleteSound(*i); } } /* Interface */ bool loadSoundFile(const std::string &name, const std::string &filepath) { SoundBuffer *buf = loadOggFile(filepath); if(buf) addBuffer(name, buf); return false; } bool loadSoundData(const std::string &name, const std::string &filedata) { // The vorbis API sucks; just write it to a file and use vorbisfile // TODO: Actually load it directly from memory std::string basepath = porting::path_user + DIR_DELIM + "cache" + DIR_DELIM + "tmp"; std::string path = basepath + DIR_DELIM + "tmp.ogg"; verbosestream<<"OpenALSoundManager::loadSoundData(): Writing " <<"temporary file to ["<<path<<"]"<<std::endl; fs::CreateAllDirs(basepath); std::ofstream of(path.c_str(), std::ios::binary); of.write(filedata.c_str(), filedata.size()); of.close(); return loadSoundFile(name, path); } void updateListener(v3f pos, v3f vel, v3f at, v3f up) { m_listener_pos = pos; alListener3f(AL_POSITION, pos.X, pos.Y, pos.Z); alListener3f(AL_VELOCITY, vel.X, vel.Y, vel.Z); ALfloat f[6]; f3_set(f, at); f3_set(f+3, -up); alListenerfv(AL_ORIENTATION, f); warn_if_error(alGetError(), "updateListener"); } void setListenerGain(float gain) { alListenerf(AL_GAIN, gain); } int playSound(const std::string &name, bool loop, float volume) { maintain(); if(name == "") return 0; SoundBuffer *buf = getFetchBuffer(name); if(!buf){ infostream<<"OpenALSoundManager: \""<<name<<"\" not found." <<std::endl; return -1; } return playSoundRaw(buf, loop, volume); } int playSoundAt(const std::string &name, bool loop, float volume, v3f pos) { maintain(); if(name == "") return 0; SoundBuffer *buf = getFetchBuffer(name); if(!buf){ infostream<<"OpenALSoundManager: \""<<name<<"\" not found." <<std::endl; return -1; } return playSoundRawAt(buf, loop, volume, pos); } void stopSound(int sound) { maintain(); deleteSound(sound); } bool soundExists(int sound) { maintain(); return (m_sounds_playing.count(sound) != 0); } void updateSoundPosition(int id, v3f pos) { std::map<int, PlayingSound*>::iterator i = m_sounds_playing.find(id); if(i == m_sounds_playing.end()) return; PlayingSound *sound = i->second; alSourcei(sound->source_id, AL_SOURCE_RELATIVE, false); alSource3f(sound->source_id, AL_POSITION, pos.X, pos.Y, pos.Z); alSource3f(sound->source_id, AL_VELOCITY, 0, 0, 0); alSourcef(sound->source_id, AL_REFERENCE_DISTANCE, 30.0); } }; ISoundManager *createOpenALSoundManager(OnDemandSoundFetcher *fetcher) { OpenALSoundManager *m = new OpenALSoundManager(fetcher); if(m->m_is_initialized) return m; delete m; return NULL; };