From 40b6bbbdf34bdc7e337bf394b987e527388a5442 Mon Sep 17 00:00:00 2001 From: "glassmancody.info" Date: Sat, 23 Oct 2021 13:46:39 -0700 Subject: [PATCH] use openmw define system --- components/shader/shadervisitor.cpp | 4 +++- files/shaders/objects_fragment.glsl | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/shader/shadervisitor.cpp b/components/shader/shadervisitor.cpp index 9b54060730..2c673200f7 100644 --- a/components/shader/shadervisitor.cpp +++ b/components/shader/shadervisitor.cpp @@ -559,7 +559,7 @@ namespace Shader if (auto partsys = dynamic_cast(&node)) { - writableStateSet->setDefine("SOFT_PARTICLES", "1", osg::StateAttribute::ON); + defineMap["softParticles"] = "1"; auto depth = SceneUtil::createDepth(); depth->setWriteMask(false); @@ -568,6 +568,8 @@ namespace Shader writableStateSet->addUniform(new osg::Uniform("opaqueDepthTex", 2)); writableStateSet->setTextureAttributeAndModes(2, mOpaqueDepthTex, osg::StateAttribute::ON); } + else + defineMap["softParticles"] = "0"; std::string shaderPrefix; if (!node.getUserValue("shaderPrefix", shaderPrefix)) diff --git a/files/shaders/objects_fragment.glsl b/files/shaders/objects_fragment.glsl index cb435c7790..d750a4dd1f 100644 --- a/files/shaders/objects_fragment.glsl +++ b/files/shaders/objects_fragment.glsl @@ -1,6 +1,5 @@ #version 120 #pragma import_defines(FORCE_OPAQUE) -#pragma import_defines(SOFT_PARTICLES) #if @useUBO #extension GL_ARB_uniform_buffer_object : require @@ -81,7 +80,7 @@ varying vec3 passNormal; #include "parallax.glsl" #include "alpha.glsl" -#if defined(SOFT_PARTICLES) && SOFT_PARTICLES +#if @softParticles #include "softparticles.glsl" #endif @@ -225,7 +224,7 @@ void main() #endif gl_FragData[0].xyz = mix(gl_FragData[0].xyz, gl_Fog.color.xyz, fogValue); -#if defined(SOFT_PARTICLES) && SOFT_PARTICLES +#if @softParticles gl_FragData[0].a *= calcSoftParticleFade(); #endif