Jump to content

Error motionblur disappear after f5


NqwSqw

Recommended Posts

Hi

I want to solve an error of a mod called MotionBlur that give player a blur effect but while toggling perspective, the blur disappear.

So, i created a method to when player toggle perspective, it give blur but it's buggy like it works with Third Person View but Third Person Rear View and First Person View doesn't work.

Here is the code:

@SubscribeEvent
    public void onKey(final InputEvent.KeyInputEvent event) {
        if (this.mc.thePlayer != null && MotionBlurMod.isEnabled && Keyboard.isKeyDown(this.mc.gameSettings.keyBindTogglePerspective.getKeyCode())) {
            try {
                //final Method method = ReflectionHelper.findMethod((Class)EntityRenderer.class, (Object)this.mc.entityRenderer, new String[] { "loadShader", "func_175069_a" }, new Class[] { ResourceLocation.class });
            	this.mc.entityRenderer.loadShader(new ResourceLocation("motionblur", "motionblur"));
                this.mc.entityRenderer.getShaderGroup().createBindFramebuffers(this.mc.displayWidth, this.mc.displayHeight);
            }
            catch (Exception ex) {}
        }
    }
Quote

Also, multiple error pop-up when toggling perspective: 

[Client thread/WARN]: Could not find uniform named InSize in the specified shader program.
 [Client thread/WARN]: Could not find uniform named InSize in the specified shader program.
 [Client thread/WARN]: Could not find uniform named InSize in the specified shader program.
 

 

Link to comment
Share on other sites

more src code would be better for us to get a understanding how the code works. and taking a guess form the error message inside your shader program(i am assuming this is the motionblur file) you don't have a uniform with the InSize name.

Link to comment
Share on other sites

17 hours ago, Discult said:

more src code would be better for us to get a understanding how the code works. and taking a guess form the error message inside your shader program(i am assuming this is the motionblur file) you don't have a uniform with the InSize name.

public void execute(final MinecraftServer server, final ICommandSender sender, final String[] args) {
        if (args.length == 0) {
        	sender.addChatMessage((ITextComponent)new TextComponentString("Usage: /motionblur <0 - 10>."));
        }
        else {
            final int amount = NumberUtils.toInt(args[0], -1);
            if (amount >= 0 && amount <= 10) {
                if (MotionBlurMod.isFastRenderEnabled()) {
                	sender.addChatMessage((ITextComponent)new TextComponentString("Motion blur does not work if Fast Render is enabled, please disable it in Options > Video Settings > Performance."));
                }
                else {
                    if (this.mc.entityRenderer.getShaderGroup() != null) {
                        this.mc.entityRenderer.getShaderGroup().deleteShaderGroup();
                    }
                    if (amount != 0) {
                        MotionBlurMod.isEnabled = true;
                        MotionBlurMod.blurAmount = amount;
                        try {
                        	final Method method = ReflectionHelper.findMethod((Class)EntityRenderer.class, (Object)this.mc.entityRenderer, new String[] { "loadShader", "loadShader" }, new Class[] { ResourceLocation.class });
                            method.invoke(this.mc.entityRenderer, new ResourceLocation("motionblur", "motionblur"));
                            this.mc.entityRenderer.getShaderGroup().createBindFramebuffers(this.mc.displayWidth, this.mc.displayHeight);
                            sender.addChatMessage((ITextComponent)new TextComponentString("Motion blur enabled."));
                        }
                        catch (Throwable ex) {
                        	sender.addChatMessage((ITextComponent)new TextComponentString("Failed to enable Motion blur."));
                            ex.printStackTrace();
                        }
                    }
                    else {
                        MotionBlurMod.isEnabled = false;
                        sender.addChatMessage((ITextComponent)new TextComponentString("Motion blur disabled."));
                    }
                }
            }
            else {
            	sender.addChatMessage((ITextComponent)new TextComponentString("Invalid amount."));
            }
        }
    }

Here is MotionBlurCommand class

@Mod(name = "MotionBlurMod", modid = "motionblurmod", version = "1.0", acceptedMinecraftVersions = "*")
public class MotionBlurMod
{
    private Minecraft mc;
    private Map domainResourceManagers;
    public static double blurAmount;
    public static boolean isEnabled;
    
    public MotionBlurMod() {
        this.mc = Minecraft.getMinecraft();
    }
    
    @Mod.EventHandler
    public void init(final FMLInitializationEvent event) {
        ClientCommandHandler.instance.registerCommand((ICommand)new MotionBlurCommand());
        MinecraftForge.EVENT_BUS.register((Object)this);
    }
    
    @SubscribeEvent
    public void onClientTick(final TickEvent.ClientTickEvent event) {
        if (this.domainResourceManagers == null) {
            try {
                for (final Field field : SimpleReloadableResourceManager.class.getDeclaredFields()) {
                    if (field.getType() == Map.class) {
                        field.setAccessible(true);
                        this.domainResourceManagers = (Map)field.get(Minecraft.getMinecraft().getResourceManager());
                        break;
                    }
                }
            }
            catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        if (!this.domainResourceManagers.containsKey("motionblur")) {
            this.domainResourceManagers.put("motionblur", new MotionBlurResourceManager());
        }
    }
    
    @SubscribeEvent
    public void onKey(final InputEvent.KeyInputEvent event) {
        if (this.mc.thePlayer != null && MotionBlurMod.isEnabled && Keyboard.isKeyDown(this.mc.gameSettings.keyBindTogglePerspective.getKeyCode())) {
            try {
            	final Method method = ReflectionHelper.findMethod((Class)EntityRenderer.class, (Object)this.mc.entityRenderer, new String[] { "loadShader", "loadShader" }, new Class[] { ResourceLocation.class });
                method.invoke(this.mc.entityRenderer, new ResourceLocation("motionblur", "motionblur"));
                this.mc.entityRenderer.getShaderGroup().createBindFramebuffers(this.mc.displayWidth, this.mc.displayHeight);
            }
            catch (Exception ex) {}
        }
    }
    
    public static boolean isFastRenderEnabled() {
        try {
            final Field fastRender = GameSettings.class.getDeclaredField("ofFastRender");
            return fastRender.getBoolean(Minecraft.getMinecraft().gameSettings);
        }
        catch (Exception var1) {
            return false;
        }
    }
    
    static {
        MotionBlurMod.blurAmount = 0.75;
        MotionBlurMod.isEnabled = false;
    }
}

Here MotionBlurMod main class

public class MotionBlurResource implements IResource
{
    private static final String JSON = "{\"targets\":[\"swap\",\"previous\"],\"passes\":[{\"name\":\"phosphor\",\"intarget\":\"minecraft:main\",\"outtarget\":\"swap\",\"auxtargets\":[{\"name\":\"PrevSampler\",\"id\":\"previous\"}],\"uniforms\":[{\"name\":\"Phosphor\",\"values\":[%.2f, %.2f, %.2f]}]},{\"name\":\"blit\",\"intarget\":\"swap\",\"outtarget\":\"previous\"},{\"name\":\"blit\",\"intarget\":\"swap\",\"outtarget\":\"minecraft:main\"}]}";
    
    public InputStream getInputStream() {
        final double amount = 0.7 + MotionBlurMod.blurAmount / 100.0 * 3.0 - 0.01;
        return IOUtils.toInputStream(String.format(Locale.ENGLISH, "{\"targets\":[\"swap\",\"previous\"],\"passes\":[{\"name\":\"phosphor\",\"intarget\":\"minecraft:main\",\"outtarget\":\"swap\",\"auxtargets\":[{\"name\":\"PrevSampler\",\"id\":\"previous\"}],\"uniforms\":[{\"name\":\"Phosphor\",\"values\":[%.2f, %.2f, %.2f]}]},{\"name\":\"blit\",\"intarget\":\"swap\",\"outtarget\":\"previous\"},{\"name\":\"blit\",\"intarget\":\"swap\",\"outtarget\":\"minecraft:main\"}]}", amount, amount, amount));
    }
    
    public boolean hasMetadata() {
        return false;
    }
    
    public IMetadataSection getMetadata(final String metadata) {
        return null;
    }
    
    public ResourceLocation getResourceLocation() {
        return null;
    }
    
    public String getResourcePackName() {
        return null;
    }

    public void close() throws IOException {
    }
}

Here MotionBlurRessource class 

public class MotionBlurResourceManager implements IResourceManager
{
    public Set<String> getResourceDomains() {
        return null;
    }
    
    public IResource getResource(final ResourceLocation location) throws IOException {
        return (IResource)new MotionBlurResource();
    }
    
    public List<IResource> getAllResources(final ResourceLocation location) throws IOException {
        return null;
    }
}

Then MotionBlurRessourceManager class

 

Anyways, what does it mean "don't have a uniform with the InSize name" ?

Thank you for replying

Link to comment
Share on other sites

I found this explanation here

 
 
 
 
 
 
5
Quote

These are warnings when Minecraft tries to pass a Uniform variable (that is declared in the program json) to the fsh and vsh programs but either one or both never reference the uniform variable or OpenGL optimized out the variable for being unused. It shouldn't affect shader performance or compilation in any way. Perhaps the fix would be for the Minecraft code to just not output a warning when it fails to send a uniform to a specific shader program? Maybe only output the warning if both vsh and fsh do not use the uniform.

That's from here: https://bugs.mojang.com/browse/MC-103633

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • What MC version? What's the IP? Are any mods needed to be able to join?
    • Thank you for your answer ! Unfortunatly i have the same problem when i use setPos() public static int movingfunction(CommandContext<CommandSourceStack> context){ CommandSourceStack source = context.getSource(); if (!(source.getEntity() instanceof ServerPlayer)) { return 0; } ServerPlayer player = (ServerPlayer ) source.getEntity(); double moveSpeed = 0.5; for (int i =0; i<10000;i++) { LOGGER.info("running for the {} time", i); double x = player.getX() + player.getViewVector(1.0f).x * moveSpeed; double y = player.getY(); double z = player.getZ() + player.getViewVector(1.0f).z * moveSpeed ; Vec3 movementVec = new Vec3(x, y, z); LOGGER.info("x ={} y ={} z ={}", x, y, z); player.setPos( movementVec); } return 1; } With the logs i can see that x and z are increasing but once again my player is not moving. is there a function to use to sync the server and the client ? I also tried to use LocalPlayer instead of ServerPlayer but my code would stop when i got the object. Also i will change a bit the main topic but is there a way to similate key press ? i found KeyBinding.setKeyBindState on others post but it look like there is no more KeyBinding in 1.20   I found this code : KeyMapping.click(Minecraft.getInstance().options.keyUp.getKey()); But it doesn't seems to work   And i found this one : Minecraft.getInstance().options.keyUp.setDown(true); wich works but doesn't exactly do what i want , it doesn't release the key so for exemple i can't make him run. Minecraft.getInstance().options.keyUp.setDown(true); Minecraft.getInstance().options.keyUp.setDown(false); Minecraft.getInstance().options.keyUp.setDown(true); doesn't make him run
    • Add crash-reports with sites like https://paste.ee/ Maybe an issue with blur, essentials or cumulus_menus
    • Add the crash-report or latest.log (logs-folder) with sites like https://paste.ee/ and paste the link to it here  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.