GithubHelp home page GithubHelp logo

Comments (9)

cadaver avatar cadaver commented on May 2, 2024

If billboards don't billboard with relative = true, that's a bug. Could not reproduce it on MSVC; need to try MinGW.

There currently is certainly a bug that switching the relative mode during runtime causes the particles to become invisible unless updateInvisible is also set to true.

from urho3d.

JTippetts avatar JTippetts commented on May 2, 2024

I'm not switching relative mode at run-time, just setting it when the emitter is instanced. Here are a couple of shots to (kind of) show the issue. When a projectile moves, it's orientation is set to pivot around the vertical axis in the direction (x and z) that it is moving. In this first shot, I shoot the fireball to the left:

http://i.imgur.com/fJ0Kk4T.jpg

In this one, I shoot the fireball straight ahead.

http://i.imgur.com/OivJLQr.jpg

You can see that the particles are being viewed somewhat on-end now. If I shoot the fireball to the right, nothing at all is visible. These are the settings (not XML, since I'm not using XML, but you should get the gist of them):

{type="ParticleEmitter", Material="Materials/flame.xml", UpdateInvisible=true, NumParticles=2000,
Sorted=false, Relative=true, MinRotationSpeed=-60, MaxRotationSpeed=60, MinDirection=Vector3(-0.125,-1,-0.125), MaxDirection=Vector3(0.125,-1,0.125),
MinVelocity=0.5, MaxVelocity=1, MinParticleSize=Vector2(0.25, 0.25), MaxParticleSize=Vector2(0.5,0.5), TimeToLive=1, MinEmissionRate=50, MaxEmissionRate=100,
ConstantForce=Vector3(0,1,0), Color=Color(0.5,0.25,0.125)
}

If Relative is switched to false, the effect is visible from any direction, but the effect is not quite what I'm looking for in all cases.

from urho3d.

cadaver avatar cadaver commented on May 2, 2024

That looks like you're using a (vertex) shader that is not billboard-capable, or alternatively you somehow have a more complex than usual scene rendering setup that confuses the camera rotation shader uniform that's supposed to ensure that billboards are always camera-aligned.

Can you post the flame material's technique xml and the shader description xml for the shader referred to in it?

from urho3d.

JTippetts avatar JTippetts commented on May 2, 2024

It does make sense to sometimes have the orientation of the billboard follow the node; ie, for something like a ground shockwave portion of an explosion, or some kind of ground-hugging swirling fog particle, that wants to orient itself along the vertical axis. So always forcing the particles to billboard toward the camera might not be the right answer either. I was thinking more of a flag that would force camera billboarding if set, or allow following the parent node orientation if not set and if relative is set. It would likely be ignored if relative were not set, since in that case the only logical alternative is camera billboarding.

from urho3d.

JTippetts avatar JTippetts commented on May 2, 2024

The flame material:

material
technique name="Techniques/DiffVColAdd.xml"
texture unit="diffuse" name="Textures/flame1.png"
/material

Technique:

technique
pass name="alpha" vs="Unlit_VCol" ps="Unlit_DiffVCol" depthwrite="false" blend="add"
/technique

The camera is added as a component of a node that is the child of another node. Could that be part of the problem?

-- Inside a ScriptObject Start() method for the combat mode camera:

self.cameranode=self.node:CreateChild("CamNode")
self.camera=self.cameranode:CreateComponent("Camera")

-- Inside a method of the combat camera ScriptObject called upon update:
-- follow specifies the zoom distance, vertangle specifies the angle above the horizontal to set

self.node:SetPositionXYZ(self.pos.x, self.pos.y, self.pos.z)
self.node:SetRotation(Quaternion(self.camangle+90, Vector3(0,-1,0)))
self.cameranode:SetPositionXYZ(0, self.follow_math.sin(self.vertangle_math.pi/180), -self.follow_math.cos(self.vertangle_math.pi/180))
self.cameranode:LookAt(Vector3(self.pos.x, self.pos.y, self.pos.z), Vector3(0,1,0))

from urho3d.

JTippetts avatar JTippetts commented on May 2, 2024

The shader description and technique are Urho3D defaults, by the way. I haven't dipped into custom shaders quite yet.

from urho3d.

cadaver avatar cadaver commented on May 2, 2024

At first I thought the shader uniforms weren't handling a parented camera correctly, but it turned out to be a bug in the billboard shader code. It was mixing the camera's orientation with the scene node's orientation, which is certainly incorrect.

Now that the fix is pushed, it isn't straightforward to simply enable non-billboarded mode from the emitter, as the final orientation is controlled by shader code that purposefully disregards the node orientation. Instead it requires writing a customized billboard shader that does take the node orientation into account. Look at the function GetBillboardPos() in Transform.vert, which is now doing

return (modelMatrix * iPos).xyz + iSize.x * cViewRightVector + iSize.y * cViewUpVector;

To enable node orientation, the custom version would need to be something like:

return modelMatrix * vec4(iPos.xyz + iSize.x * vec3(1.0, 0.0, 0.0) + iSize.y * vec3(0.0, 1.0, 0.0), 1.0);

from urho3d.

JTippetts avatar JTippetts commented on May 2, 2024

Okay, awesome. Thank you for jumping on this. I really do appreciate the work you're doing. I'd send you cookies, but I doubt they'd travel internationally very well. :D

from urho3d.

friesencr avatar friesencr commented on May 2, 2024

yeah @cadaver where is your beer fund! do they not have beer in Finland? its either that or digital hugs from a neckbeard.

from urho3d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.