particle coloration work
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-09-20 16:56:48 -04:00
parent 491ccf4409
commit 112cf26bad
10 changed files with 20 additions and 36 deletions

View File

@ -371,6 +371,7 @@
"dimension1" : 0.2,
"dimension2" : 1.6,
"dimension3" : 0.2,
"linearFriction": 0.001,
"mass": 0.3,
"rotX": 0,
"rotY": 0,

View File

@ -255,6 +255,7 @@
"dimension1" : 0.2,
"dimension2" : 1.6,
"dimension3" : 0.2,
"linearFriction": 0.001,
"mass": 0.3,
"rotX": 0,
"rotY": 0,

View File

@ -1,23 +1,5 @@
{
"foliageList" : [
{
"id" : "FallOak1",
"tokens" : [
"BLENDER_ROTATION"
],
"physicsObjects" : [
{
"type" : "CYLINDER",
"dimension1" : 0.1,
"dimension2" : 0.45,
"dimension3" : 0.1,
"offsetX" : 0,
"offsetY" : 0.45,
"offsetZ" : 0
}
],
"modelPath" : "Models/falloak1.fbx"
},
{
"id" : "Green Grass",
"tokens" : [

View File

@ -11,7 +11,7 @@
{
"id" : "particleEmitterTest",
"particleEmitter": {
"maxLife": 40,
"maxLife": 20,
"lifeCurrent": 0,
"particleVelocity": {
"x": 0.0,
@ -19,14 +19,14 @@
"z": 0.0
},
"acceleration": -0.01,
"texture": "blood1.png",
"texture": "flame_05.png",
"size": 0.3,
"color": {
"x": 0.5,
"y": 0.5,
"z": 0.5
},
"frequency": 1
"frequency": 2
},
"tokens": [
]

View File

@ -77,7 +77,7 @@ in vec3 ViewFragPos;
in vec3 Normal;
in vec2 TexCoord;
in vec4 FragPosLightSpace;
in vec4 color;
in vec4 instanceColor;
uniform vec3 viewPos;
@ -120,7 +120,7 @@ void main(){
//get color of base texture
// vec3 textureColor = vec3((norm.x + 1) / 2.0, norm.y, 1.0 - (norm.x + 1) / 2.0);
vec4 textureColor = texture(material.diffuse,TexCoord);
vec4 textureColor = texture(material.diffuse,TexCoord) * instanceColor;
// vec3 textureColor = vec3(0.17647,0.4,0.09411);//texture(material.diffuse, TexCoord).rgb;
//shadow
@ -150,11 +150,12 @@ void main(){
// }
//calculate weight function
float weight = clamp(pow(min(1.0, finalColor.a * 10.0) + 0.01, 3.0) * 1e8 *
float weight = clamp(pow(min(1.0, finalColor.a * 10.0) + 0.01, 3.0) * 1e3 *
pow(1.0 - gl_FragCoord.z * 0.9, 3.0), 1e-2, 3e3);
//emit colors
accum = vec4(finalColor.rgb * finalColor.a, finalColor.a) * weight;
// accum = finalColor * weight;
reveal = finalColor.a;
}

View File

@ -40,17 +40,15 @@ out vec3 FragPos;
out vec3 ViewFragPos;
out vec2 TexCoord;
out vec4 FragPosLightSpace;
out vec4 color;
out vec4 instanceColor;
void main() {
ParticleData currentParticle = particleData[gl_InstanceID];
ParticleData currentData = particleData[gl_InstanceID];
mat4 model = currentData.model;
color = currentData.color;
mat4 model = currentParticle.model;
//normalize posiiton and normal
vec4 FinalVertex = vec4(aPos, 1.0);
@ -67,10 +65,11 @@ void main() {
Normal = mat3(transpose(inverse(model))) * aNormal;
//offset based on data stored in particle data
TexCoord = (aTex * currentData.texture.xy) + currentData.texture.zw;
TexCoord = (aTex * currentParticle.texture.xy) + currentParticle.texture.zw;
instanceColor = currentParticle.color;
//shadow map stuff
//shadow map stuff
FragPosLightSpace = lightSpaceMatrix * vec4(FragPos, 1.0);

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file
#Thu Sep 19 23:04:32 EDT 2024
buildNumber=355
#Fri Sep 20 15:37:40 EDT 2024
buildNumber=359

View File

@ -216,7 +216,7 @@ public class FoliageCell {
}
List<String> foliageTypesSupported = Globals.gameConfigCurrent.getVoxelData().getTypeFromId(data.getType(voxelPosition)).getAmbientFoliage();
boolean airAbove = data.getType(voxelPosition.x,voxelPosition.y+1,voxelPosition.z) == 0;
if(foliageTypesSupported != null && airAbove && scale < 3){
if(foliageTypesSupported != null && foliageTypesSupported.size() > 0 && airAbove && scale < 3){
shouldGenerate = true;
}
if(shouldGenerate){

View File

@ -70,7 +70,7 @@ public class ClientParticleTree implements BehaviorTree {
this.acceleration = particleData.getAcceleration();
this.hasLife = particleData.getMaxLife() != null;
this.lifeCurrent = maxLife;
this.color = new Vector3d(new Random().nextFloat(),new Random().nextFloat(),new Random().nextFloat());
this.color = new Vector3d(new Random().nextFloat(),new Random().nextFloat(),0);
}
public int getMaxLife() {
@ -130,7 +130,7 @@ public class ClientParticleTree implements BehaviorTree {
new Quaternionf(rotation),
scale
));
instancedActor.setAttribute(Globals.particleService.getColorAttrib(), new Vector4f((float)this.color.x,(float)this.color.y,(float)this.color.z,1.0f));
instancedActor.setAttribute(Globals.particleService.getColorAttrib(), new Vector4f((float)this.color.y,(float)this.color.z,1.0f,(float)this.color.x));
//when written to buffer, will be written in order w, x, y, z
//but gpu will fetch in order x, y, z, w